不错
为了 ruby,我入了 macbookpro2016
好吧,我还是不往坑里跳了,用 linux 吧!
#1 楼 @huacnlee #3 楼 @nickcen 这么搞的
<%= form_for(@project, :html => {:class => 'form-horizontal'} ) do |f| %>
<div class="form-group">
<label for="inputName" class="col-sm-2 control-label">名称</label>
<div class="col-sm-10">
<%= f.text_field :name ,:class => 'form-control', :id => 'inputName', :placeholder => 'project name' %>
</div>
</div>
<div class="form-group">
<label for="inputDescription" class="col-sm-2 control-label">描述</label>
<div class="col-sm-10">
<%= f.text_area :description, :class => 'form-control', :rows => '4', :id => 'inputDescription', :placeholder => 'project description' %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<!-- rails checkbox -->
<% @users.each do |user| %>
<div class="checkbox">
<%= check_box_tag 'users[]', user.id%>
<%= label_tag user.username %>
</div>
<% end %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.submit "保存", class: "btn btn-primary" %>
<%= button_tag "重置", type: :reset, class: 'btn btn-danger' %>
</div>
</div>
<% end %>
后台
def create
@project = Project.new(project_params)
user_ids = params[:users]
# binding.pry
user_ids.each do |user_id|
user = User.find(user_id)
user.update_attribute(:project, @project)
end
respond_to do |format|
if @project.save
flash[:success] = '项目添加成功!'
format.html { redirect_to projects_path }
else
format.html { render action: 'new' }
end
end
end
这货跟为知笔记比,出去大牌,还有什么优点?
#7 楼 @Rei == AddQuantityToLineItems: reverting ========================================= -- remove_column(:line_items, :quantity, :integer, {:default=>1}) -> 0.0127s == AddQuantityToLineItems: reverted (0.0286s) ================================
== AddQuantityToLineItems: migrating ========================================= -- add_column(:line_items, :quantity, :integer, {:default=>1}) -> 0.0005s == AddQuantityToLineItems: migrated (0.0006s) ================================