ruby-on-rails-3

rails joins with module name

邮差的信 提交于 2020-03-01 09:35:30
问题 Here is how to join two models User.where(:id => 1).joins(:posts) but how to join two models with module/namspace @schedules= Swimming::Classschedule.joins(:Swimming::Slot).where(:date => @date) seems not working properly (with error message) :Swimming is not a class/module UPDATE I have updated to @schedules= Swimming::Classschedule.joins(:swimming_slots).where(:date => @date) and I do have this table create_table :swimming_classschedules do |t| t.integer :slot_id t.integer :coach_id t

Ruby on rails DRY strip whitespace from selective input forms

余生长醉 提交于 2020-02-27 12:28:28
问题 I'm fairly new to rails so bear with me. I want to strip whitespace from a selective group of input forms. But I would like a DRY solution. So I was thinking there might be a solution such as a helper method, or a custom callback. Or a combination such as before_validation strip_whitespace(:attribute, :attribute2, etc) Any help is awesome! Thanks! EDIT I have this in my model file ... include ApplicationHelper strip_whitespace_from_attributes :employer_name ... and I have this in my

Custom POST routes for create action not fired up

巧了我就是萌 提交于 2020-02-26 11:15:25
问题 # Explaining the context puts "I am learning Rails, building a simple forum application." puts "I am pretty satisfied to where I got so far but routes... " puts "...still figuring them out." puts "Been 2 days trying all sorts of things." puts "This is where I am now, and something is not working as expected." puts "Any help/pointers would be appreciated! :)" # The Problem puts "I want my forum's create path to be '/helpcenter' and not '/helpcenter/cat'." puts "When I access the form to create

ransack search form in header partial: No Ransack::Search object was provided to search_form_for

為{幸葍}努か 提交于 2020-02-26 07:33:04
问题 First of all, I'm new to RoR, so the answer may be obvious, in which case I apologize. I've looked around and haven't found anything that helps. I'm trying to have a search form at the header of every web page on my app that will search through the names of all my "buckets". Here is the relevant code: In app/views/layouts/_header.html.erb (within a nav bar): <% search_form_for @q do |f| %> <%= f.label :name_cont %> <%= f.text_field :name_cont %> <%= f.submit %> <% end %> In app/controllers

Dynamic finder methods for validation purposes

て烟熏妆下的殇ゞ 提交于 2020-02-25 03:26:31
问题 I am using Ruby on Rails 3.0.7 and I would like to find some records at run time for validation purposes but passing\setting a value for that finder method. That is, in a my class I have the following: class Group < < ActiveRecord::Base validates :relation_id, :presence => true, :inclusion => { :in => ... # Read below for more information about } end If I set :in to be :in => User.find(1).group_ids it works, but I would like to set "some-dynamic-things" for the finder method instead of the 1

Dynamic finder methods for validation purposes

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-25 03:20:29
问题 I am using Ruby on Rails 3.0.7 and I would like to find some records at run time for validation purposes but passing\setting a value for that finder method. That is, in a my class I have the following: class Group < < ActiveRecord::Base validates :relation_id, :presence => true, :inclusion => { :in => ... # Read below for more information about } end If I set :in to be :in => User.find(1).group_ids it works, but I would like to set "some-dynamic-things" for the finder method instead of the 1

Dynamic finder methods for validation purposes

泄露秘密 提交于 2020-02-25 03:20:27
问题 I am using Ruby on Rails 3.0.7 and I would like to find some records at run time for validation purposes but passing\setting a value for that finder method. That is, in a my class I have the following: class Group < < ActiveRecord::Base validates :relation_id, :presence => true, :inclusion => { :in => ... # Read below for more information about } end If I set :in to be :in => User.find(1).group_ids it works, but I would like to set "some-dynamic-things" for the finder method instead of the 1

What are the main reasons for passenger server shut down periodically?

淺唱寂寞╮ 提交于 2020-02-21 05:01:30
问题 In my rails application, I am using Apache + ruby 1.9.2p180 + Rails 3.0.5 + Phusion Passenger version 3.0.13 Can somebody please tell me why my passenger shut down periodically. Somebody please help This is the last error after which the application stops working [Fri Aug 31 02:07:23 2012] [error] [client 141.212.121.10] Premature end of script headers: [ pid=17952 thr=1 file=ext/apache2/Hooks.cpp:817 time=2012-08-31 02:07:23.257 ]: The backend application (process 13680) did not send a valid

What are the main reasons for passenger server shut down periodically?

微笑、不失礼 提交于 2020-02-21 05:00:32
问题 In my rails application, I am using Apache + ruby 1.9.2p180 + Rails 3.0.5 + Phusion Passenger version 3.0.13 Can somebody please tell me why my passenger shut down periodically. Somebody please help This is the last error after which the application stops working [Fri Aug 31 02:07:23 2012] [error] [client 141.212.121.10] Premature end of script headers: [ pid=17952 thr=1 file=ext/apache2/Hooks.cpp:817 time=2012-08-31 02:07:23.257 ]: The backend application (process 13680) did not send a valid

Display link in Rails form error message

六月ゝ 毕业季﹏ 提交于 2020-02-18 05:07:28
问题 On our sign-up form, we validates_uniqueness_of :email When the a user is attempting to use our sign up form and they specify an existing email address, I'd like them to see an error message like this This email address is already in use. If you're having trouble logging in, you can reset your password Obviously, I'd like to use the named route for the link, but my User model does not have access to it. How can I accomplish this? Side note: We will be offering translations for our app soon