So I am making a rails app that lets users search logs by date. So in my controller I have set it to look for logs from the DB using the parameters. However when it first loads, there are no parameters passed to the controller, so it gives a nil error. Is there a way to set the default parameters so that it won''t have this error? Here are the controller and view snippets: user_sessions_controller.rb [...] def admin @start_date = Date::civil(params[:find_dates] [''start_date(1i)''].to_i, params[:find_dates][''start_date(2i)''].to_i, params[:find_dates][''start_date(3i)''].to_i) @end_date = Date::civil(params[:find_dates]["end_date(1i)"].to_i, params[:find_dates]["end_date(2i)"].to_i, params[:find_dates] ["end_date(3i)"].to_i) @logs = Log.all(:conditions => ["updated_at between ? and ?", @start_date, @end_date], :order => "updated_at DESC") respond_to do |format| format.html { render :action => ''admin'' } format.csv { render :csv => @logs } end end [...] admin.html.erb [...] <div id="find_dates"> <% form_tag ''/find_dates'' do %> <p> <%= label_tag "start_date", "Start Date" %> <%= date_select "find_dates", "start_date", :order => [:month, :day, :year] %> </p> <p> <%= label_tag "end_date", "End Date" %> <%= date_select "find_dates", "end_date", :order => [:month, :day, :year] %> </p> <%= submit_tag "Find" %> <% end %> </div> [...] -- 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 22 March 2010 16:34, Civ2boss <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So I am making a rails app that lets users search logs by date. So in > my controller I have set it to look for logs from the DB using the > parameters. However when it first loads, there are no parameters > passed to the controller, so it gives a nil error. > > Is there a way to set the default parameters so that it won''t have > this error? > > Here are the controller and view snippets: > > user_sessions_controller.rb > > [...] > def admin > > @start_date = Date::civil(params[:find_dates] > [''start_date(1i)''].to_i, params[:find_dates][''start_date(2i)''].to_i, > params[:find_dates][''start_date(3i)''].to_i)Test params[:find_dates] before you use it and take appropriate action if nil. Colin> > @end_date = Date::civil(params[:find_dates]["end_date(1i)"].to_i, > params[:find_dates]["end_date(2i)"].to_i, params[:find_dates] > ["end_date(3i)"].to_i) > > @logs = Log.all(:conditions => ["updated_at between ? and ?", > @start_date, @end_date], :order => "updated_at DESC") > > respond_to do |format| > format.html { render :action => ''admin'' } > format.csv { render :csv => @logs } > end > > end > [...] > > > > admin.html.erb > > [...] > <div id="find_dates"> > <% form_tag ''/find_dates'' do %> > <p> > <%= label_tag "start_date", "Start Date" %> > <%= date_select "find_dates", "start_date", :order => > [:month, :day, :year] %> > </p> > <p> > <%= label_tag "end_date", "End Date" %> > <%= date_select "find_dates", "end_date", :order => > [:month, :day, :year] %> > </p> > <%= submit_tag "Find" %> > <% end %> > </div> > [...] > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
How would I go about testing the parameter? On Mar 22, 1:35 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 22 March 2010 16:34, Civ2boss <civ2b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > So I am making a rails app that lets users search logs by date. So in > > my controller I have set it to look for logs from the DB using the > > parameters. However when it first loads, there are no parameters > > passed to the controller, so it gives a nil error. > > > Is there a way to set the default parameters so that it won''t have > > this error? > > > Here are the controller and view snippets: > > > user_sessions_controller.rb > > > [...] > > def admin > > > @start_date = Date::civil(params[:find_dates] > > [''start_date(1i)''].to_i, params[:find_dates][''start_date(2i)''].to_i, > > params[:find_dates][''start_date(3i)''].to_i) > > Test params[:find_dates] before you use it and take appropriate action if nil. > > Colin > > > > > @end_date = Date::civil(params[:find_dates]["end_date(1i)"].to_i, > > params[:find_dates]["end_date(2i)"].to_i, params[:find_dates] > > ["end_date(3i)"].to_i) > > > @logs = Log.all(:conditions => ["updated_at between ? and ?", > > @start_date, @end_date], :order => "updated_at DESC") > > > respond_to do |format| > > format.html { render :action => ''admin'' } > > format.csv { render :csv => @logs } > > end > > > end > > [...] > > > admin.html.erb > > > [...] > > <div id="find_dates"> > > <% form_tag ''/find_dates'' do %> > > <p> > > <%= label_tag "start_date", "Start Date" %> > > <%= date_select "find_dates", "start_date", :order => > > [:month, :day, :year] %> > > </p> > > <p> > > <%= label_tag "end_date", "End Date" %> > > <%= date_select "find_dates", "end_date", :order => > > [:month, :day, :year] %> > > </p> > > <%= submit_tag "Find" %> > > <% end %> > > </div> > > [...] > > > -- > > 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 athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
params[:find_dates].nil? On Mar 22, 12:22 pm, Civ2boss <civ2b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How would I go about testing the parameter? > > On Mar 22, 1:35 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > On 22 March 2010 16:34, Civ2boss <civ2b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > So I am making a rails app that lets users search logs by date. So in > > > my controller I have set it to look for logs from the DB using the > > > parameters. However when it first loads, there are no parameters > > > passed to the controller, so it gives a nil error. > > > > Is there a way to set the default parameters so that it won''t have > > > this error? > > > > Here are the controller and view snippets: > > > > user_sessions_controller.rb > > > > [...] > > > def admin > > > > @start_date = Date::civil(params[:find_dates] > > > [''start_date(1i)''].to_i, params[:find_dates][''start_date(2i)''].to_i, > > > params[:find_dates][''start_date(3i)''].to_i) > > > Test params[:find_dates] before you use it and take appropriate action if nil. > > > Colin > > > > @end_date = Date::civil(params[:find_dates]["end_date(1i)"].to_i, > > > params[:find_dates]["end_date(2i)"].to_i, params[:find_dates] > > > ["end_date(3i)"].to_i) > > > > @logs = Log.all(:conditions => ["updated_at between ? and ?", > > > @start_date, @end_date], :order => "updated_at DESC") > > > > respond_to do |format| > > > format.html { render :action => ''admin'' } > > > format.csv { render :csv => @logs } > > > end > > > > end > > > [...] > > > > admin.html.erb > > > > [...] > > > <div id="find_dates"> > > > <% form_tag ''/find_dates'' do %> > > > <p> > > > <%= label_tag "start_date", "Start Date" %> > > > <%= date_select "find_dates", "start_date", :order => > > > [:month, :day, :year] %> > > > </p> > > > <p> > > > <%= label_tag "end_date", "End Date" %> > > > <%= date_select "find_dates", "end_date", :order => > > > [:month, :day, :year] %> > > > </p> > > > <%= submit_tag "Find" %> > > > <% end %> > > > </div> > > > [...] > > > > -- > > > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks that works! I was trying params[:find_dates] == nil, params[:find_dates].blank?, params[:find_dates] == " ", but obviously none of them worked. Here''s an sort of off-topic question how would I go about getting format.csv { render :csv => @logs } to work? Rails gives a method not found error. I did use the routes.rb file to give that admin page a direct link, but even if I use the full "controller/action" url, it still says not found. Do I need to give that a direct link in the routes.rb file also or am I missing something? On Mar 22, 4:11 pm, "E. Litwin" <elit...-ur4TIblo6goN+BqQ9rBEUg@public.gmane.org> wrote:> params[:find_dates].nil? > > On Mar 22, 12:22 pm, Civ2boss <civ2b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > How would I go about testing the parameter? > > > On Mar 22, 1:35 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > On 22 March 2010 16:34, Civ2boss <civ2b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > So I am making a rails app that lets users search logs by date. So in > > > > my controller I have set it to look for logs from the DB using the > > > > parameters. However when it first loads, there are no parameters > > > > passed to the controller, so it gives a nil error. > > > > > Is there a way to set the default parameters so that it won''t have > > > > this error? > > > > > Here are the controller and view snippets: > > > > > user_sessions_controller.rb > > > > > [...] > > > > def admin > > > > > @start_date = Date::civil(params[:find_dates] > > > > [''start_date(1i)''].to_i, params[:find_dates][''start_date(2i)''].to_i, > > > > params[:find_dates][''start_date(3i)''].to_i) > > > > Test params[:find_dates] before you use it and take appropriate action if nil. > > > > Colin > > > > > @end_date = Date::civil(params[:find_dates]["end_date(1i)"].to_i, > > > > params[:find_dates]["end_date(2i)"].to_i, params[:find_dates] > > > > ["end_date(3i)"].to_i) > > > > > @logs = Log.all(:conditions => ["updated_at between ? and ?", > > > > @start_date, @end_date], :order => "updated_at DESC") > > > > > respond_to do |format| > > > > format.html { render :action => ''admin'' } > > > > format.csv { render :csv => @logs } > > > > end > > > > > end > > > > [...] > > > > > admin.html.erb > > > > > [...] > > > > <div id="find_dates"> > > > > <% form_tag ''/find_dates'' do %> > > > > <p> > > > > <%= label_tag "start_date", "Start Date" %> > > > > <%= date_select "find_dates", "start_date", :order => > > > > [:month, :day, :year] %> > > > > </p> > > > > <p> > > > > <%= label_tag "end_date", "End Date" %> > > > > <%= date_select "find_dates", "end_date", :order => > > > > [:month, :day, :year] %> > > > > </p> > > > > <%= submit_tag "Find" %> > > > > <% end %> > > > > </div> > > > > [...] > > > > > -- > > > > 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@googlegroups.com. > > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 March 2010 15:04, Civ2boss <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks that works! I was trying params[:find_dates] == nil,params[:find_dates] == nil is the same as params[:find_dates].nil? Colin -- 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.
Well that''s strange then, because it still gave me a unexpected nil found error when I use that. Actually now that I think about it, I might have been using it on params[:find_dates][''start_date(1i)''] instead of just the params[:find_dates]. On Tue, Mar 23, 2010 at 11:12 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 March 2010 15:04, Civ2boss <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Thanks that works! I was trying params[:find_dates] == nil, > > params[:find_dates] == nil is the same as params[:find_dates].nil? > > Colin > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 March 2010 15:20, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well that''s strange then, because it still gave me a unexpected nil > found error when I use that. Actually now that I think about it, I > might have been using it on params[:find_dates][''start_date(1i)''] > instead of just the params[:find_dates].That would explain it, params[:find_dates][''start_date(1i)''] == nil would generate an error if params[:find_dates] is nil because it would attempt to evaluate nil.[''start_date(1i)''] first. Colin -- 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.
Yeah thanks for the help! By the way do you know how I can get the "format.csv { render :csv => @logs }" part to work? I have tested it on an index page and that works, but when I try it on this admin page it says it doesn''t understand the URL. I have set a direct path to the admin page instead of the standard "controller/action" path in the routes.rb file, but even if i go through the "controller/action" path it still says it can''t find it. Is it because of that direct path in the routes.rb that it''s giving me the error? On Tue, Mar 23, 2010 at 11:24 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 March 2010 15:20, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Well that''s strange then, because it still gave me a unexpected nil >> found error when I use that. Actually now that I think about it, I >> might have been using it on params[:find_dates][''start_date(1i)''] >> instead of just the params[:find_dates]. > > That would explain it, params[:find_dates][''start_date(1i)''] == nil > would generate an error if params[:find_dates] is nil because it would > attempt to evaluate nil.[''start_date(1i)''] first. > > Colin > > -- > 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. > >-- 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 23 March 2010 16:03, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yeah thanks for the help! > > By the way do you know how I can get the "format.csv { render :csv => > @logs }" part to work? I have tested it on an index page and that > works, but when I try it on this admin page it says it doesn''t > understand the URL. I have set a direct path to the admin page instead > of the standard "controller/action" path in the routes.rb file, but > even if i go through the "controller/action" path it still says it > can''t find it. Is it because of that direct path in the routes.rb that > it''s giving me the error?Have you got the .:format bit in the route? Otherwise I would suggest a new thread for this question as routing is not my high point. Colin -- 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.
I don''t, but I figure there must be a way to just have it in the controllers. Oh well thanks, I''ll start another thread. On Tue, Mar 23, 2010 at 12:17 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 March 2010 16:03, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Yeah thanks for the help! >> >> By the way do you know how I can get the "format.csv { render :csv => >> @logs }" part to work? I have tested it on an index page and that >> works, but when I try it on this admin page it says it doesn''t >> understand the URL. I have set a direct path to the admin page instead >> of the standard "controller/action" path in the routes.rb file, but >> even if i go through the "controller/action" path it still says it >> can''t find it. Is it because of that direct path in the routes.rb that >> it''s giving me the error? > > Have you got the .:format bit in the route? Otherwise I would suggest > a new thread for this question as routing is not my high point. > > Colin > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23 March 2010 16:31, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t, but I figure there must be a way to just have it in the > controllers. Oh well thanks, I''ll start another thread.You don''t what? It is best to insert your reply at the appropriate point in the comment so that it is easier to follow the thread. If you mean that you don''t have the .:format in the route where you are using some_url.csv then that is the problem. Colin> > On Tue, Mar 23, 2010 at 12:17 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 23 March 2010 16:03, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> Yeah thanks for the help! >>> >>> By the way do you know how I can get the "format.csv { render :csv => >>> @logs }" part to work? I have tested it on an index page and that >>> works, but when I try it on this admin page it says it doesn''t >>> understand the URL. I have set a direct path to the admin page instead >>> of the standard "controller/action" path in the routes.rb file, but >>> even if i go through the "controller/action" path it still says it >>> can''t find it. Is it because of that direct path in the routes.rb that >>> it''s giving me the error? >> >> Have you got the .:format bit in the route? Otherwise I would suggest >> a new thread for this question as routing is not my high point. >> >> Colin >> >> -- >> 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. >> >> > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Mar 23, 2010 at 12:43 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 March 2010 16:31, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I don''t, but I figure there must be a way to just have it in the >> controllers. Oh well thanks, I''ll start another thread. > > You don''t what? It is best to insert your reply at the appropriate > point in the comment so that it is easier to follow the thread. If > you mean that you don''t have the .:format in the route where you are > using some_url.csv then that is the problem.hmm yeah that''s what I meant. Thanks I think I figured it out. This is the code I will use in the routes.rb file: map.admin ''admin.:format'', :controller => ''user_sessions'', :action => ''admin''> Colin > >> >> On Tue, Mar 23, 2010 at 12:17 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>> On 23 March 2010 16:03, Robin Ting <civ2boss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> Yeah thanks for the help! >>>> >>>> By the way do you know how I can get the "format.csv { render :csv => >>>> @logs }" part to work? I have tested it on an index page and that >>>> works, but when I try it on this admin page it says it doesn''t >>>> understand the URL. I have set a direct path to the admin page instead >>>> of the standard "controller/action" path in the routes.rb file, but >>>> even if i go through the "controller/action" path it still says it >>>> can''t find it. Is it because of that direct path in the routes.rb that >>>> it''s giving me the error? >>> >>> Have you got the .:format bit in the route? Otherwise I would suggest >>> a new thread for this question as routing is not my high point. >>> >>> Colin >>> >>> -- >>> 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. >>> >>> >> >> -- >> 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. >> >> > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.