我希望在我的页面顶部而非标准的Rails闪现消息中创建自定义的jQuery消息。我想在我的赞同按钮附近创建一个闪现消息。
我的控制器:
def vote_up
@post = Post.find(params[:id])
current_user.up_vote(@post)
flash[:message] = 'Thanks for voting!'
redirect_to(root_path, :notice => 'Tak for dit indlæg, det er nu online!')
rescue MakeVoteable::Exceptions::AlreadyVotedError
flash[:error] = 'Already voted!'
redirect_to root_path
end
我的观点:
<% @posts.each do |post| %>
<h1><%= post.titel %></h1>
<p><%= post.body_html %></p>
<p><%= link_to 'Vote up', stem_op_path(post.id) %> BRUGERNAVN: <%= post.user.username %> | UPVOTES: <%= post.up_votes %> | DOWN VOTES: <%= post.down_votes %> OPRETTET: <%= post.created_at.strftime("%d %B") %><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></p>
</tr>
<% end %>