I have a model in which I have a boolean attribute, published
. In my Post
controller I have added it to my permitted attributes. Like this:
params.require(:post).permit([...], :published)
My index action that should list all published posts looks like this:
def index
if session[:user_id]
@posts = Post.paginate(:page => params[:page])
else
@posts = Post.where("published = 1").paginate(:page => params[:page])
end
end
And lastly my form looks like this:
= form_for @post, :html => { :multipart => true } do |f|
[...]
.field
= f.label :published, "Publicera:"
= f.check_box :published
.actions
= f.submit
Currently no posts is listen on my index page, even if I either the new or updat view checks the checkbox. And I'm not sure how to fix it, any ideas?