控制器
def create
@info = Info.new
end
def new
@info = Info.new(info_params)
if @info.save
flash[:success] = "Welcome!"
else
#
end
end
路由:
root 'static_pages#home'
get 'infos/:content' => 'infos#create'
resources :infos, only:[:create, :destroy, :extract]
match '/create_message', to: 'infos#create', via: 'get'
页面里的表单
<% provide(:title, 'New Message') %>
<div class="row">
<div class="span6 offset3">
<%= form_for(@info) do |f| %>
<%= f.label :content %>
<%= f.text_field :content %>
<br>
<%= f.submit "Create a Message" , class: "btn" %>
<% end %>
</div>
</div>
点了提交后,从 rails console 里没有看到应该被保存到的字段,没有直接用 scaffold,想自己写出来就遇到问题了。求解答。