Hello, I try this : in application_helper.rb ----------------------- def lnk bla return link_to bla, { :controller => bli , :action => "blo" , :id => "blu" } end in file.rhtml ----------- <%= lnk "yo!" %> This return an error. There is a way to do this or something similar, or this is completly impossible ? Thanks
On 1/16/06, oo00oo <oo00oo@free.fr> wrote:> Hello, I try this : > > in application_helper.rb > ----------------------- > > def lnk bla > return link_to bla, { :controller => bli , :action => "blo" , :id > => "blu" }I think you mean :controller => "bli", right? In the future, it''s nice to give the actual error you receive when stuff doesn''t work. Joe> end > > in file.rhtml > ----------- > > <%= lnk "yo!" %> > > This return an error. There is a way to do this or something similar, or > this is completly impossible ? > > Thanks > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
in my example, I forgot the "", sorry def lnk bla return link_to bla, { :controller => "bli" , :action => "blo" , :id => "blu" } end The error returned is : SyntaxError in # ./script/../config/../app/helpers/application_helper.rb:22: syntax error ./script/../config/../app/helpers/application_helper.rb:61: class definition in method body ./script/../config/../app/helpers/application_helper.rb:74: syntax error RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in `load'' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in `load'' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:in `require_or_load'' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in `depend_on'' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in `require_dependency'' d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in `require_dependency'' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/helpers.rb:114:in `default_helper_module!'' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/helpers.rb:127:in `send'' d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/helpers.rb:127:in `inherited_without_api'' d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service/container/action_controller_container.rb:86:in `inherited_without_action_controller'' d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service/dispatcher/action_controller_dispatcher.rb:34:in `inherited'' #{RAILS_ROOT}/app/controllers/application.rb:1 -e:3:in `load'' -e:3 Hello, I try this : in application_helper.rb ----------------------- def lnk bla return link_to bla, { :controller => bli , :action => "blo" , :id => "blu" } I think you mean :controller => "bli", right? In the future, it''s nice to give the actual error you receive when stuff doesn''t work. Joe end in file.rhtml ----------- <%= lnk "yo!" %> This return an error. There is a way to do this or something similar, or this is completly impossible ? Thanks _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
The link break in the middle of the statement, does that exist in the actual code. Does that would definitely cause the error. oo00oo wrote:> > >in my example, I forgot the "", sorry > > >def lnk bla > return link_to bla, { :controller => "bli" , :action => "blo" , :id >=> "blu" } >end > >The error returned is : > > > > > SyntaxError in <controller not set>#<action not set> > > ./script/../config/../app/helpers/application_helper.rb:22: syntax error > ./script/../config/../app/helpers/application_helper.rb:61: class > definition in method body > ./script/../config/../app/helpers/application_helper.rb:74: syntax error > > |RAILS_ROOT: ./script/../config/..| > > Application Trace <http://localhost:3003/colors/infos/9#> | Framework > Trace <http://localhost:3003/colors/infos/9#> | Full Trace > <http://localhost:3003/colors/infos/9#> > >|d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in `load'' >d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in `load'' >d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:in `require_or_load'' >d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in `depend_on'' >d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in `require_dependency'' >d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in `require_dependency'' >d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/helpers.rb:114:in `default_helper_module!'' >d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/helpers.rb:127:in `send'' >d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/helpers.rb:127:in `inherited_without_api'' >d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service/container/action_controller_container.rb:86:in `inherited_without_action_controller'' >d:/ruby/lib/ruby/gems/1.8/gems/actionwebservice-1.0.0/lib/action_web_service/dispatcher/action_controller_dispatcher.rb:34:in `inherited'' >#{RAILS_ROOT}/app/controllers/application.rb:1 >-e:3:in `load'' >-e:3| > > > > >>>Hello, I try this : >>> >>>in application_helper.rb >>>----------------------- >>> >>>def lnk bla >>> return link_to bla, { :controller => bli , :action => "blo" , :id >>>=> "blu" } >>> >>> >> >>I think you mean :controller => "bli", right? >> >>In the future, it''s nice to give the actual error you receive when >>stuff doesn''t work. >> >>Joe >> >> >> >>>end >>> >>>in file.rhtml >>>----------- >>> >>><%= lnk "yo!" %> >>> >>>This return an error. There is a way to do this or something similar, or >>>this is completly impossible ? >>> >>>Thanks >>>_______________________________________________ >>>Rails mailing list >>>Rails@lists.rubyonrails.org >>>http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >>_______________________________________________ >>Rails mailing list >>Rails@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> >> > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >
On 16 Jan ''06, at 9:50 AM, oo00oo wrote:> def lnk bla > return link_to bla, { :controller => "bli" , :action => > "blo" , :id > => "blu" } > endIf there really is a line break before ''=>'' in your source code, then that''s a syntax error. I took your code and pasted it into my app, removing that line break, and it compiles fine, apart from a warning that you should put parens around the method arguments. I have similar methods in my own code. --Jens