0

I have a project a github which can be found here: https://github.com/marcvanderpeet12/bloccitmaster

I have the following problem:

But it does not seem to save in the right folder. Any quick thoughts on what goes wrong?

fuzzyalej
  • 5,903
  • 2
  • 31
  • 49
user3706202
  • 197
  • 1
  • 3
  • 14
  • WHat is wrong is that you are trying to save it in a file. Use database! – BroiSatse Jan 16 '15 at 10:51
  • when asking, post relevant parts of code which produce unexpected results instead of repository link, not so much people would like to check it and dig into your sources – Rustam Gasanov Jan 16 '15 at 11:45

1 Answers1

2

You need to associate the topic to the post before you save. You do this by assigning the topic to your Post instance.

def create
  @topic = Topic.find(params[:topic_id])
  @post = current_user.posts.build(params.require(:post).permit(:title, :body))

  # Add this line
  @post.topic = @topic

  authorize @post
  if @post.save
    flash[:notice] = "Post was saved."
    redirect_to [@topic, @post]
  else
    flash[:error] = "There was an error saving the post"
    render :new
  end
end