All,
I have numerous places in my codebase like this:
redirect_to :action => ''schedule_by_uid_and_run_date'',
:uid =>
@schedule.first.train_uid, :year => @date.year, :month => @date.month,
:day => @date.day
I''d like to replace the :year, :month and :day parameters with a hash
containing the three parameters. @date is an instance of a Date class,
and the trouble with that is Date.month is a single character. I''d
like
it to be null-padded, but it seems messy to put .rjust(2, ''0'')
against
all three parameters everywhere in the code.
Is it possible to do something like this?
redirect_to :action => ''foo'', :uid =>
@schedule.first.train_uid,
params_hash
...where params_hash contains { :year => ''2011'', :month
=> ''01'', :day =>
''19'' }
Cheers,
Peter
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
http://apidock.com/rails/ActionController/Redirecting/redirect_to assuming
you use rails 3.1
this might work :
redirect_to {:action => ''foo'', :uid =>
@schedule.first.train_uid,
params_hash}.merge(param_hash)
Ahmy Yulrizka
On Fri, Jan 20, 2012 at 5:41 AM, Peter Hicks
<peter.hicks-AEjVCzJlOor10XsdtD+oqA@public.gmane.org>wrote:
> redirect_to
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
sorry redirect_to {:action => ''foo'', :uid =>
@schedule.first.train_uid}.merge(param_hash)
Ahmy Yulrizka
On Fri, Jan 20, 2012 at 4:21 PM, Ahmy Yulrizka
<ahmy135-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> params_hash
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Jan 20, 2012 at 04:22:14PM +0700, Ahmy Yulrizka wrote:> sorry redirect_to {:action => ''foo'', :uid => @schedule.first.train_uid}.merge(param_hash)I think I tried that already, but I''ll give it a go. I settled on... redirect_to :action => ''foo'', :uid => ..., nil => param_hash ...but I''m not sure if it feels horribly dirty or elegantly smart. Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hai:
# create virtual models
# year_entry.rb
attr_accessor :year,
:month,
:day
# controller:
@year_entry_access = []
year_var = YearEntry.new
year_var.year = 2012
year_var.month = 1
year_var.day = 20
@year_entry_access << year_var
redirect_to :action=>show_rrr,:year_entry_access =>@year_entry_access
# After that you can pass other method
def show_rrr
if params[:year_entry_access] # here you can get params_hash format
params[:year_entry_access].each_value do |get_date|
get_date[:date]
get_month[:month]
get_year[:year]
end
end
end
# you can access like this way "get_date[:date]"
Bye:)
bdeveloper
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.