Hi all! I''m new to rails. When trying to process a form post, I''m getting the following error output in logs/development.log. I don''t know why it''s complaining about /layouts/application.rhtml since I use that layout in every page that''s rendered on my site. It works fine everywhere but here. ------------------------- Processing SupportController#license (for 127.0.0.1 at Tue May 10 09:37:42 EST 2005) Parameters: {"submit"=>"Find License Number(s)", "action"=>"license", "controller"=>"support", "email"=>"joe_lester-ee4meeAH724@public.gmane.org"} Customer Load (0.007496) SELECT * FROM customers WHERE email LIKE ''joe_lester-ee4meeAH724@public.gmane.org'' Rendering support/license within layouts/application Rendering layouts/application (200 OK) ActionView::TemplateError (undefined method `include?'' for nil:NilClass) on line #1 of /layouts/application.rhtml: <head> <meta name="description" content="SomethingSoftware makes Macintosh software. Our programs include IconIt, Balance, and more cool things to come...</html> </div>la? 2005 SOMETHING SOFTWARE. /gems/actionpack-1.7.0/lib/action_view/helpers/ asset_tag_helper.rb:82:in `compute_public_path'' /gems/actionpack-1.7.0/lib/action_view/helpers/ asset_tag_helper.rb:68:in `image_tag'' (erb):1:in `evaluate_locals'' /gems/actionpack-1.7.0/lib/action_view/base.rb:265:in `evaluate_locals'' /gems/actionpack-1.7.0/lib/action_view/base.rb:275:in `rhtml_render'' /gems/actionpack-1.7.0/lib/action_view/base.rb:201:in `send'' /gems/actionpack-1.7.0/lib/action_view/base.rb:201:in `render_template'' /gems/actionpack-1.7.0/lib/action_view/base.rb:181:in `render_file'' /gems/actionpack-1.7.0/lib/action_controller/base.rb:458:in `render_file'' /gems/actionpack-1.7.0/lib/action_controller/base.rb:440:in `render_without_layout'' /gems/actionpack-1.7.0/lib/action_controller/layout.rb:209:in `render_without_benchmark'' /gems/actionpack-1.7.0/lib/action_controller/benchmarking.rb: 22:in `render'' /gems/actionpack-1.7.0/lib/action_controller/benchmarking.rb: 22:in `measure'' /gems/actionpack-1.7.0/lib/action_controller/benchmarking.rb: 22:in `render'' /gems/actionpack-1.7.0/lib/action_controller/base.rb:701:in `perform_action_without_filters'' /gems/actionpack-1.7.0/lib/action_controller/filters.rb:294:in `perform_action_without_benchmark'' /gems/actionpack-1.7.0/lib/action_controller/benchmarking.rb: 30:in `perform_action_without_rescue'' /gems/actionpack-1.7.0/lib/action_controller/benchmarking.rb: 30:in `measure'' /gems/actionpack-1.7.0/lib/action_controller/benchmarking.rb: 30:in `perform_action_without_rescue'' /gems/actionpack-1.7.0/lib/action_controller/rescue.rb:79:in `perform_action'' /gems/actionpack-1.7.0/lib/action_controller/base.rb:330:in `send'' /gems/actionpack-1.7.0/lib/action_controller/base.rb:330:in `process'' /gems/actionpack-1.7.0/lib/action_controller/base.rb:273:in `process'' /gems/rails-0.11.1/lib/dispatcher.rb:32:in `dispatch'' /Users/joe/shareware/public/dispatch.fcgi:20 /Users/joe/shareware/public/dispatch.fcgi:18:in `each_cgi'' /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each'' /usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each_cgi'' /Users/joe/shareware/public/dispatch.fcgi:18 Rendering /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.7.0/lib/ action_controller/templates/rescues/layout.rhtml (500 Internal Error) ------------------------- The license method in my Support controller looks like this... def license @message_text = "Sorry. We could not find any license numbers for the email address you provided. Please hit the back button and try again." email_address = @request.parameters["email"] licenses = Customer.find_by_sql("SELECT * FROM customers WHERE email LIKE ''" + email_address + "''") if (licenses.size > 0) @message_text = "We found your license number(s) and sent an email to " + email_address + ". Please check your inbox." end end @message_text is then referenced in the view (license.rhtml). If I change the license method to the following, it works fine... def license render_text("hi") end If anyone could offer me some pointers, I would be much obliged. Thanks! _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
i can not help you with your problem, but your code has a big security hole. it is open to sql-injection attacks: licenses = Customer.find_by_sql("SELECT * FROM customers WHERE email LIKE ''" + email_address + "''") better use: licenses = Customer.find_by_email @params[''email'']> The license method in my Support controller looks like this... > > > def license > @message_text = "Sorry. We could not find any license numbers for > the email address you provided. Please hit the back button and try > again." > email_address = @request.parameters["email"] > licenses = Customer.find_by_sql("SELECT * FROM customers WHERE > email LIKE ''" + email_address + "''") > if (licenses.size > 0) > @message_text = "We found your license number(s) and sent an > email to " + email_address + ". Please check your inbox." > end > end >-- Norman Timmler Holländische Reihe 31 22765 Hamburg +49 (0)40 / 43 25 10 80 mailto:norman-QkIQCVqxERM@public.gmane.org _ ASCII ribbon campaign ( ) - against HTML email X & vCards / \
I would place a breakpoint in Support#license after SQL query and check what is returned. Might be futile still main purpose of breakpoint is self help in situations like these. Please see http://wiki.rubyonrails.com/rails/show/HowtoDebugWithBreakpoint for a good reference. Cheers, Zsombor On 5/10/05, Norman Timmler <norman-QkIQCVqxERM@public.gmane.org> wrote:> i can not help you with your problem, but your code has a big security > hole. it is open to sql-injection attacks: > licenses = Customer.find_by_sql("SELECT * FROM customers WHERE email > LIKE ''" + email_address + "''") > > better use: > licenses = Customer.find_by_email @params[''email''] > > > The license method in my Support controller looks like this... > > > > > > def license > > @message_text = "Sorry. We could not find any license numbers for > > the email address you provided. Please hit the back button and try > > again." > > email_address = @request.parameters["email"] > > licenses = Customer.find_by_sql("SELECT * FROM customers WHERE > > email LIKE ''" + email_address + "''") > > if (licenses.size > 0) > > @message_text = "We found your license number(s) and sent an > > email to " + email_address + ". Please check your inbox." > > end > > end > > > > -- > Norman Timmler > Holländische Reihe 31 > 22765 Hamburg > > +49 (0)40 / 43 25 10 80 > > mailto:norman-QkIQCVqxERM@public.gmane.org > > _ > ASCII ribbon campaign ( ) > - against HTML email X > & vCards / \ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://deezsombor.blogspot.com
Norman, thanks for the heads up about security. On May 10, 2005, at 10:51 AM, Norman Timmler wrote:> i can not help you with your problem, but your code has a big security > hole. it is open to sql-injection attacks: > licenses = Customer.find_by_sql("SELECT * FROM customers WHERE email > LIKE ''" + email_address + "''") > > better use: > licenses = Customer.find_by_email @params[''email''] > > >> The license method in my Support controller looks like this... >> >> >> def license >> @message_text = "Sorry. We could not find any license numbers for >> the email address you provided. Please hit the back button and try >> again." >> email_address = @request.parameters["email"] >> licenses = Customer.find_by_sql("SELECT * FROM customers WHERE >> email LIKE ''" + email_address + "''") >> if (licenses.size > 0) >> @message_text = "We found your license number(s) and sent an >> email to " + email_address + ". Please check your inbox." >> end >> end >> >> > > -- > Norman Timmler > Holländische Reihe 31 > 22765 Hamburg > > +49 (0)40 / 43 25 10 80 > > mailto:norman-QkIQCVqxERM@public.gmane.org > > _ > ASCII ribbon campaign ( ) > - against HTML email X > & vCards / \ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Thanks to all who responded. It turns out that, in my license method, I was forgetting to define a variable which /layouts/application.rhtml required. I''m so glad it''s working now! Joe On May 10, 2005, at 10:24 AM, Joe Lester wrote:> Hi all! I''m new to rails. > > When trying to process a form post, I''m getting the following error > output in logs/development.log. I don''t know why it''s complaining > about /layouts/application.rhtml since I use that layout in every > page that''s rendered on my site. It works fine everywhere but here. > > ------------------------- > > Processing SupportController#license (for 127.0.0.1 at Tue May 10 > 09:37:42 EST 2005) > Parameters: {"submit"=>"Find License Number(s)", > "action"=>"license", "controller"=>"support", > "email"=>"joe_lester-ee4meeAH724@public.gmane.org"} > Customer Load (0.007496) SELECT * FROM customers WHERE email > LIKE ''joe_lester-ee4meeAH724@public.gmane.org'' > Rendering support/license within layouts/application > Rendering layouts/application (200 OK) > > ActionView::TemplateError (undefined method `include?'' for > nil:NilClass) on line #1 of /layouts/application.rhtml: > ------------------------- > > The license method in my Support controller looks like this... > > def license > @message_text = "Sorry. We could not find any license numbers > for the email address you provided. Please hit the back button and > try again." > email_address = @request.parameters["email"] > licenses = Customer.find_by_sql("SELECT * FROM customers WHERE > email LIKE ''" + email_address + "''") > if (licenses.size > 0) > @message_text = "We found your license number(s) and sent > an email to " + email_address + ". Please check your inbox." > end > end > > @message_text is then referenced in the view (license.rhtml). If I > change the license method to the following, it works fine... > > def license > render_text("hi") > end > > If anyone could offer me some pointers, I would be much obliged. > Thanks!_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails