Hey I was trying to make an association in devise so a user can just have a link to his association (like he can just click new post and he can make it) but i cant make it in devise like regular rails, it seems really common but no one seems able to help me (or they dont know what im talking about), I tried manually making come controllers and views but i get a problem (500 internal server error) heres 开发者_运维知识库my log file https://github.com/Kevin-Mohamed/mygit any other information needed let me know
OK, so this is off the top of my head, so YMMV. There's plenty of ways to go around this, but here's one way... Don't try to get devise to do more than it should.
class User
#devise links go here
has_many :pictures
end
class Picture
belongs_to :user
end
#routes
namespace :my do
resources :pictures
end
class ApplicationController
# current_user gets set here by devise
end
class PicturesController
def create
@picture = current_user.pictures.build(params[:picture])
end
end
#In your view you'd have the following, which would post to /my/pictures
=form_for(my_pictures_path(@picture)) do |f|
... etc
精彩评论