[Nitro] Q about helper :form

Michael Fellinger m.fellinger at gmail.com
Sat Aug 5 01:07:47 EDT 2006


yes, please require 'part/admin' after the other stuff... that should fix it :)

On 8/5/06, Alexander Lazic <al-nitrogen at none.at> wrote:
> Hi,
>
> i'am now at the end of the first screencast and have stopped and started
> the demo.rb.
>
> I was very suprised to get the following error:
>
> ---
> ruby demo.rb
> ./controller.rb:2: undefined method `helper' for Hello:Class (NoMethodError)
>         from /home/al/progs/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
>         from demo.rb:10
> ---
>
> The demo.rb is now:
>
> ---
> require 'rubygems'
> # or
> # ruby -rubygems demo.rb
>
> require 'nitro'
> require 'og'
>
> require 'part/admin'
> require 'model'
> require 'controller'
>
> # default sqllite3
> Og.start
>
> Nitro.start Hello
> ---
>
> the controller.rb
> ---
> class Hello
>   helper :form
>
>   def index
>     %{
>
>       Hello World
>       <br/>
>       <a href="test"> test</a>
>       <br/>
>       <a href="list"> list</a>
>     }
>   end
>
>   # lets refactor a bit
>   def list
>     @users = User.all
>   end
>
>   def delete(oid)
>     User.delete(oid)
>     redirect_to_referer
>   end
>
>   # intelligent dispatching = no rewrite rules!!
>   def test(name,pass)
>     %{
>       The Time is #{Time.now}.
>       <br/><br/>
>       The name is #{name}.
>       <br/>
>       The pass is #{pass}.
>     }
>   end
>
>   def another
>     @hello = 'Hello from controller'
>   end
>
>   def init_db
>     User.create 'gsmox'
>     User.create 'stella'
>     User.create 'tassos'
>     redirect_to_referer
>   end
> end
> ---
>
> and the list.xhtml
> ---
> <html>
>   <h1> User List </h1>
>
>   <ul unless="@users.empty?">
>     <li for="user in @users"> #{user} (<a href="delete/#{user.oid}">delete</a>)</li>
>   </ul>
>     <span if="@users.empty?"> No users </span>
>
>   <hr/>
>
>   #{form_for User.find_by_name('gsmox')}
> </html>
> ---
>
> The unbelivable for me is if i remove the 'helper :form' and start after
> the start i add this line back the reload is ok without a error
> message?!
>
> Does anybody understand this?!
>
> Regards
>
> Alex
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>


More information about the Nitro-general mailing list