Play with Rails Console

app is another local variable which is avaliable to you,  It’s a local variable you get for free in script/console. An instance of

ActionController::Integration::Session

$ ruby script/console
Loading development environment. 
>> app.url_for(:controller => 'stories', :action => 'show', :id => '10002')
=> "http://www.example.com/stories/10002" 
>> app.get '/stories/10002'
=> 200 
>> app.assigns(:story)
=> #<Story:0x24aad0c ... > 
>> app.path 
=> "/stories/10002" 
>> app.reset! 
=> nil 
>> app.get '/yeah/right/dude'
=> 404 
>> app.post '/account/login', { :username => 'username', :password => 'password' }  
=> 200 
>> app.cookies
=> {"_session_id"=>"9d1c014f42881524ff6cb81fb5b594bc"}

Comments

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Difference between Validations, Callbacks and Observers