ruby-on-rails-3

Persistent Ruby segfaulting after a clean install

懵懂的女人 提交于 2020-01-13 14:05:06
问题 Ruby keeps segfaulting when using the Koala gem to talk over HTTP: /Users/pawel/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault I've tried the following: Run which -a ruby which showed multiple Rubies via MacPorts. So I deleted those and running the same command again returns only /usr/bin/ruby I've removed the MacPorts version of PostgreSQL and installed it with Homebrew instead (With MacPorts, it installs its own version of OpenSSL) Running openssl version

Sqlite3 reference deploying simple heroku Rails application

僤鯓⒐⒋嵵緔 提交于 2020-01-13 14:02:01
问题 I've got a problem deploying a very simple example rails app on Heroku. This app uses a db. In local (OSX) with sqlite3 there is no problem, but I can't push to Heroku because some lost reference to sqlite3. I've put on Gemfile the distinction between test, development and production environments: #gem 'sqlite3' group :development, :test do gem 'sqlite3' end group :production do gem 'pg' end and bundle withou problem: bundle install --without production But when i deploy to Heroku: git push

Rails is this query open to sql injection?

青春壹個敷衍的年華 提交于 2020-01-13 13:11:18
问题 I'm still learning how to write good queries using ActiveRecord. I'm curious if this query is subject to sql injection because of the way i'm using the date field in the query. Can someone please point out any obvious mistakes or any better ways to write this query? @arrangements_for_month = Arrangement.joins(:timeslot). where("timeslots.timeslot BETWEEN '#{month}' AND '#{month.end_of_month}'", params[:id]). order('location_id') 回答1: You should just use the preferred way of including

Using Rails 3 with Geokit-rails3 location gem

╄→尐↘猪︶ㄣ 提交于 2020-01-13 13:05:41
问题 I am trying to use the geokit-rails3 gem for geolocation information in a rails application. I have a simple model: class Location < ActiveRecord::Base def lookup_ip_information(post_ip) ip = post_ip location = IpGeocoder.geocode(ip) puts location.full_address lat = location.lat lng = location.lng end end When I call this method with request.remote_ip from my controller, it's throwing an error: uninitialized constant Location::IpGeocoder 回答1: I just had this issue and resolved it by entering

Find all the mongoid model names in my application

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-13 11:04:46
问题 Is there a way to find out all the Mongoid Models names in my rails app. I can find all the models just by getting all the file inside my app/models folder but i specifically want mongoid model names. 回答1: If your model classes are already loaded then you could list them by finding all the classes that include the Mongoid::Document module. Object.constants.collect { |sym| Object.const_get(sym) }. select { |constant| constant.class == Class && constant.include?(Mongoid::Document) } or if you

Installed Rails but it says I did not :)

风流意气都作罢 提交于 2020-01-13 10:58:07
问题 I just did this command to install Rails: gem install rails And it seems to have run fine and installed things. Then as I followed this tutorial: http://guides.rubyonrails.org/getting_started.html it said to do this command: rails new blog Which I did and it gave me this error: The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails Any idea why this might be the case? I thought rails was supposed to begin working automagically :) I did this

Installed Rails but it says I did not :)

不羁的心 提交于 2020-01-13 10:56:07
问题 I just did this command to install Rails: gem install rails And it seems to have run fine and installed things. Then as I followed this tutorial: http://guides.rubyonrails.org/getting_started.html it said to do this command: rails new blog Which I did and it gave me this error: The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails Any idea why this might be the case? I thought rails was supposed to begin working automagically :) I did this

Reading from serial port in a Ruby on Rails application hangs

不羁的心 提交于 2020-01-13 10:54:09
问题 I'm using the serialport gem to read from the serial port in my Ruby on Rails 3.2 application. The serial port itself is used to write data from an Arduino board. The gem is added to Gemfile . The port is initialized in application.rb : config.serial_port = SerialPort.new "/devttyACM0", 9600 config.serial_port.read_timeout = 100 The problem appears when I try to read from this port. @sp = ProjectName::Application::config.serial_port @sp.read The application hangs deadly. I've tried to perform

Reading from serial port in a Ruby on Rails application hangs

大城市里の小女人 提交于 2020-01-13 10:53:26
问题 I'm using the serialport gem to read from the serial port in my Ruby on Rails 3.2 application. The serial port itself is used to write data from an Arduino board. The gem is added to Gemfile . The port is initialized in application.rb : config.serial_port = SerialPort.new "/devttyACM0", 9600 config.serial_port.read_timeout = 100 The problem appears when I try to read from this port. @sp = ProjectName::Application::config.serial_port @sp.read The application hangs deadly. I've tried to perform

Reading from serial port in a Ruby on Rails application hangs

。_饼干妹妹 提交于 2020-01-13 10:53:15
问题 I'm using the serialport gem to read from the serial port in my Ruby on Rails 3.2 application. The serial port itself is used to write data from an Arduino board. The gem is added to Gemfile . The port is initialized in application.rb : config.serial_port = SerialPort.new "/devttyACM0", 9600 config.serial_port.read_timeout = 100 The problem appears when I try to read from this port. @sp = ProjectName::Application::config.serial_port @sp.read The application hangs deadly. I've tried to perform