ruby on rails - Displaying all Articles Created by a User Devise -
using devise on rails 4 app.
i users able view articles they've created, inside of devise edit registration page.
i have tried lots of different things in order work, cannot. awesome. here code far:
registrations_controller.rb (had manually create inside of controllers/users):
class users::registrationscontroller < devise::registrationscontroller def articles @user = user.find(params[:id]) @articles = @user.articles end end
routes.rb:
devise_for :users, controllers: { registrations: "users/registrations" }
user.rb:
has_many :articles
article.rb:
belongs_to :user
edit.html.erb (inside of views/devise/registrations):
<% @articles.each |article| %> <%= article.inspect %> <% end %>
still new rails on might doing wrong and/or best way go great. let me know if need other of code.
i think forgot add )
@ last. see this,
@user = user.find(params[:id])
Comments
Post a Comment