在rails 4中更新属性

时间:2013-10-27 11:50:29

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4

这是我的表格

<%= form_for @post do |f| %>
    <div class="input">
    <div class="input-label"><label for="title">Title</label></div>
    <div class="input-txt"><%= f.text_field :title %></div>
    </div>
    <div class="input">
    <div class="input-label"><label for="login">Description</label></div>
    <div class="input-txt txt-area"><%= f.text_area :description %></div>
    </div>

        #This will load dynamic  select boxes through ajax
        <%= select_tag label.head_name, options_for_select(generate_option(label)) %>
<% end %>

我正在更新上述表格

def update_ctrl
    @post = Post.find_by_id post_id
    @post.update_attributes(post_params) #This works
    @post.update_attributes(content: params[:style]) #This is not working
end  


private
    def post_params
        params.require(:post).permit(:title,:description)
     end

如何解决如何在控制器中获取select_tag参数的问题。有没有办法做到这一点

0 个答案:

没有答案