ruby-on-rails-3

Rails 3.1 server start fails with “Abort trap: 6”

孤街浪徒 提交于 2021-01-27 03:11:29
问题 When I try to do a rails s on my Rails 3.1 App I am getting: /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/eventmachine-0.12.10/lib/rubyeventmachine.bundle: [BUG] Segmentation fault ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0] -- control frame ---------- c:0038 p:-17557387368028 s:0124 b:0124 l:000123 d:000123 TOP c

Rails 3.1 server start fails with “Abort trap: 6”

允我心安 提交于 2021-01-27 03:06:18
问题 When I try to do a rails s on my Rails 3.1 App I am getting: /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/eventmachine-0.12.10/lib/rubyeventmachine.bundle: [BUG] Segmentation fault ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0] -- control frame ---------- c:0038 p:-17557387368028 s:0124 b:0124 l:000123 d:000123 TOP c

Rails 3.1 server start fails with “Abort trap: 6”

梦想与她 提交于 2021-01-27 03:06:01
问题 When I try to do a rails s on my Rails 3.1 App I am getting: /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/eventmachine-0.12.10/lib/rubyeventmachine.bundle: [BUG] Segmentation fault ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0] -- control frame ---------- c:0038 p:-17557387368028 s:0124 b:0124 l:000123 d:000123 TOP c

Rails 3.1 server start fails with “Abort trap: 6”

两盒软妹~` 提交于 2021-01-27 03:05:25
问题 When I try to do a rails s on my Rails 3.1 App I am getting: /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ /Users/Kyle/.rvm/gems/ruby-1.9.2-p290@skateparks/gems/eventmachine-0.12.10/lib/rubyeventmachine.bundle: [BUG] Segmentation fault ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0] -- control frame ---------- c:0038 p:-17557387368028 s:0124 b:0124 l:000123 d:000123 TOP c

Validate uniqueness of in association

徘徊边缘 提交于 2021-01-20 18:08:39
问题 Given the following classes: class Candidate has_many :applications has_many :companies, :through => :job_offers end class JobOffer belongs_to :company end class Application belongs_to :candidate belongs_to :job_offer end How can I validate the previous statement (in the image) on Rails? Adding the following validation on Application won't work when updating: def validate_uniqueness_of_candidate_within_company errors.add(:job_offer_id, "...") if candidate.companies.include?(company) end Cause

Validate uniqueness of in association

本秂侑毒 提交于 2021-01-20 18:05:22
问题 Given the following classes: class Candidate has_many :applications has_many :companies, :through => :job_offers end class JobOffer belongs_to :company end class Application belongs_to :candidate belongs_to :job_offer end How can I validate the previous statement (in the image) on Rails? Adding the following validation on Application won't work when updating: def validate_uniqueness_of_candidate_within_company errors.add(:job_offer_id, "...") if candidate.companies.include?(company) end Cause

How to display a Rails flash notice upon redirect?

若如初见. 提交于 2021-01-20 14:36:48
问题 I have the following code in a Rails controller: flash.now[:notice] = 'Successfully checked in' redirect_to check_in_path Then in the /check_in view: <p id="notice"><%= notice %></p> However, the notice does not show up. Works perfect if I don't redirect in the controller: flash.now[:notice] = 'Successfully checked in' render action: 'check_in' I need a redirect though... not just a rendering of that action. Can I have a flash notice after redirecting? 回答1: Remove the .now . So just write:

How to translate timezone full names to tz abbreviations?

别说谁变了你拦得住时间么 提交于 2020-12-29 08:48:05
问题 In a Rails 3.x app I need to display time zone abbreviations (EST, PST, CST, etc.) rather than the full time zone name. I've seen a number of discussions that seem to address the issue, but in overly verbose manners. Is there a gem or a very concise method to handle this that could be used to map them properly? 回答1: For the current time zone: Time.zone.now.strftime('%Z') Or for a list of time zones: ActiveSupport::TimeZone.us_zones.map do |zone| Time.now.in_time_zone(zone).strftime('%Z') end

Rails current_page? “fails” when method is POST

我只是一个虾纸丫 提交于 2020-12-25 03:51:58
问题 I have a really simple problem. I have a page of reports and each report has its own tab. I'm using current_page? to determine which tab should be highlighted. When I submit any report, current_page? doesn't seem to work anymore, apparently because the request method is POST . Is this the intended behavior of current_page? I have a hard time imagining why that would be the case. If it is, how do people normally get around this problem? Here's an example of a current_page? call: <li><%= link

Rails current_page? “fails” when method is POST

别等时光非礼了梦想. 提交于 2020-12-25 03:51:55
问题 I have a really simple problem. I have a page of reports and each report has its own tab. I'm using current_page? to determine which tab should be highlighted. When I submit any report, current_page? doesn't seem to work anymore, apparently because the request method is POST . Is this the intended behavior of current_page? I have a hard time imagining why that would be the case. If it is, how do people normally get around this problem? Here's an example of a current_page? call: <li><%= link