I could not word the title properly but I hope you understand. I have followed the exact example on how to generate a controller.
rails generate devise:controllers users
My routes:
devise_for :users, controllers: { sessions: "users/sessions" }
Then copy (new.html.erb) from devise/sessions to views/users/sessions, then delete the view from devise/sessions/
Then in:
class Users::SessionsController < Devise::SessionsController
def new
super
@foo = 'Bar'
end
end
Now in my views/users/sessions/new.html.erb:
<%= @foo %> # should show Bar
That not showing. Am I missing something?
This is what your SessionsController should look like:
class Users::SessionsController < Devise::SessionsController
def new
@foo = 'bar'
super
end
end
Note how super is below your custom code.
When you call super, it calls the parent method; in our case Devise::SessionsController#new. You need to initialize @foo before calling that method and rendering the new.html.erb.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With