ruby-on-rails-3

no such file to load active_record/associations/has_and_belongs_to_many_association

*爱你&永不变心* 提交于 2019-12-23 01:11:50
问题 I added the composite_primary_keys gem in my Gemfile. On local environment it runs fine, but on a centos machine it breaks with the following error. Ruby version is 1.9.2p290 and rubygems version is 1.3.7 on both environments. Does anyone know why that could be? bundle exec rake db:create --trace no such file to load -- active_record/associations/has_and_belongs_to_many_association /var/tmp/jenkins/gem_cache/myapp/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'

Rails traverse deep array of hashes

一个人想着一个人 提交于 2019-12-23 01:11:18
问题 I got this very confusing array of hashes as an API response. http://jsfiddle.net/PP9N5/ ( the full response is massive. Posting only a part of it but it covers all elements of the response) How can I get to "airlines". I tried this <% @flight["air_search_result"]["onward_solutions"]["solution"].each do|h| %> <strong><%=h["pricing_summary"]["total_fare"] %></strong> - <% h["flights"]["flight"]["segments"]["segment"].each do |s| %> <%= s['airline'] %> <% end %> <br> <hr> <% end %> And I get

Error Messages Showing in Production - Ruby on Rails 3.1, Nginx, Unicorn

心已入冬 提交于 2019-12-23 00:47:06
问题 I have a Rails 3.1 app running in production using Nginx and Unicorn. And for some reason, my custom 404 and 500 html error pages are not showing. Instead I'm getting the actual error message ("Routing Error", for example). In my production.rb file, I have config.consider_all_requests_local = false And on the same server with a nearly identical configuration, I have a 'staging' site that works just fine. The only difference, as far as I can tell, is that the production one has SSL while the

Faraday::Error::ConnectionFailed Omniauth Facebook

China☆狼群 提交于 2019-12-22 23:14:26
问题 I am getting error in rails - Faraday::Error::ConnectionFailed. I am trying RailsCast Omniauth Episode. It's working fine with Twitter. But when I give http://localhost:3000/auth/facebook it's giving error. I have also see question, but problem not solved. Settings on developer.facebook.com Site URL: http://localhost:3000/ Site Domain: localhost I am using windows. I have also read question. Thanks! 回答1: I have solved this problem. This problem might be for windows users only. Use this, 1

Faraday::Error::ConnectionFailed Omniauth Facebook

旧街凉风 提交于 2019-12-22 23:13:30
问题 I am getting error in rails - Faraday::Error::ConnectionFailed. I am trying RailsCast Omniauth Episode. It's working fine with Twitter. But when I give http://localhost:3000/auth/facebook it's giving error. I have also see question, but problem not solved. Settings on developer.facebook.com Site URL: http://localhost:3000/ Site Domain: localhost I am using windows. I have also read question. Thanks! 回答1: I have solved this problem. This problem might be for windows users only. Use this, 1

Rails 3.1 Select All checkbox

限于喜欢 提交于 2019-12-22 20:16:29
问题 this is my view: @bulk_objects.each do |bulk_warehouse| bulk_error = @wh_errors[:"bulk_warehouse#{@count}"] if @wh_errors -%> <tr class="<%= cycle("odd", "even") %>"> <%= hidden_field_tag("bulk_warehouse_id#{@count}",bulk_warehouse.id) %> <td><%= text_field_tag("bulk_warehouse_asset#{@count}", bulk_warehouse.asset, :disabled => true)%></td> <td><%= text_field_tag("bulk_warehouse_serial#{@count}", bulk_warehouse.serial, :disabled => true) %></td> <td><%= check_box_tag "enable_record#{@count}"

Rails 3.1 Select All checkbox

て烟熏妆下的殇ゞ 提交于 2019-12-22 20:15:03
问题 this is my view: @bulk_objects.each do |bulk_warehouse| bulk_error = @wh_errors[:"bulk_warehouse#{@count}"] if @wh_errors -%> <tr class="<%= cycle("odd", "even") %>"> <%= hidden_field_tag("bulk_warehouse_id#{@count}",bulk_warehouse.id) %> <td><%= text_field_tag("bulk_warehouse_asset#{@count}", bulk_warehouse.asset, :disabled => true)%></td> <td><%= text_field_tag("bulk_warehouse_serial#{@count}", bulk_warehouse.serial, :disabled => true) %></td> <td><%= check_box_tag "enable_record#{@count}"

Ruby on Rails - Ruby Operator Precedence - Parentheses

烈酒焚心 提交于 2019-12-22 20:14:03
问题 The following code results in an error Example 1 if params[:id] == '2' || params.has_key? :id abort('params id = 2 or nothing') end syntax error, unexpected tSYMBEG, expecting keyword_then or ';' or '\n' if params[:id] == '2' || params.has_key? :id However, switching the conditional statements || adding parentheses works 100%. Example 2 if params.has_key? :id || params[:id] == '2' abort('params id = 2 or nothing') end Example 3 if (params[:id] == '2') || (params.has_key? :id) abort('params id

Ruby on Rails - Ruby Operator Precedence - Parentheses

杀马特。学长 韩版系。学妹 提交于 2019-12-22 20:13:10
问题 The following code results in an error Example 1 if params[:id] == '2' || params.has_key? :id abort('params id = 2 or nothing') end syntax error, unexpected tSYMBEG, expecting keyword_then or ';' or '\n' if params[:id] == '2' || params.has_key? :id However, switching the conditional statements || adding parentheses works 100%. Example 2 if params.has_key? :id || params[:id] == '2' abort('params id = 2 or nothing') end Example 3 if (params[:id] == '2') || (params.has_key? :id) abort('params id

include root in json for array?

若如初见. 提交于 2019-12-22 20:08:26
问题 rails 3: include_root_in_json = true allows to have a root property for json response. But it doesn't work with array of object, there is a property like include_root_in_array_json? actually I have this response: [ {"model": {"a":"a_value"}}, {"model": {"b":"b_value"}}] but I want a response like that: {"models":[ {"model": {"a":"a_value"}}, {"model": {"b":"b_value"}}]} xml response has a root property 'models' which include the array, but json not... 回答1: You can try: {models: Model.all}.to