Accessing the params hash for year and month rails and using in helper

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2011-01-30T23:20:55Z Indexed on 2011/01/30 23:25 UTC
Read the original article Hit count: 237

Filed under:

So I took some php code and turned it into a calendar with a helper to make a simple calendar.

I got my data from inside the helper:

 def calendar_maker
 a = Time.now
 b = a.month
 d = a.year
 h = Time.gm(d,b,1) #first day of month

Now I want to try and do it with parameters within my method

 #from the helper file
 def calendar_maker(year, month)
 a = Time.now
 b = month
 c = year
 h = Time.gm(d,b,1) #first day of month

#from my html.erb file
<%= @month %> and <%= @year %>
<%= params["month"] %><br />
<%= params["action"] %><br />
<%= params["year"] %><br />
<%= calendar_maker( @year, @month) %>

#from controller file
def calendar
  @month = params[:month]
  @year = params[:year]
end

Anyways mistakes were made and not finding documentation anywhere or not looking in the right place. How do I get this to work with my params hash. Thanks for the help.

© Stack Overflow or respective owner

Related posts about ruby-on-rails