显示sinatra的评论

时间:2014-12-05 17:13:59

标签: sinatra

我在Sinatra上课时创建了一个微博客应用程序,但由于某种原因,我无法获取我的博客的帖子显示在页面上。如果任何人可以提供帮助,将不胜感激。我不知道我是否遗漏了代码,或者我是否错误地编写了一段代码。再次感谢

get "/post/new" do
  erb :new_post
end

post "/post/new" do
  p '++++++++++++++++++++'
  @post = Post.new(text: params[:text],
               user_id: session[:user_id])
  if @post.save
    flash[:notice] = "Post has been added"
  else
    flash[:notice] = "Your post was not created, please review and resubmit."
  end 
  redirect "/"
end

 get "/posts" do
  current_user
  @posts = Post.all

  erb :posts
end

0 个答案:

没有答案