我有一個表公司與companyid和公司名稱,併爲我公司配置有ID,companyid,公司名稱,配置一臺配置是在我的下拉由軌道摹支架產生得到公司的描述在Ruby中
如何我可以重寫/更改創建我的新配置的Ruby的保存/創建按鈕嗎? 在配置表上使用我的公司名稱還是更好地刪除它並且有一個方法geyCompanyName(id)?
我是新來的Ruby和只是想按照教程
控制器看起來像
def index
@company_config = CompanyConfig.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @company_config }
end
end
def show
@@company_config = CompanyConfig.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @company_config }
end
end
def new
@company_config = ComapnyConfig.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @company_config }
end
end
def edit
@company_config = CompanyConfig.find(params[:id])
end
def create
@company_config = CompanyConfig.new(params[:company_config])
respond_to do |format|
if @company_config.save
format.html { redirect_to @company_config, notice: 'Config was successfully created.' }
format.json { render json: @company_config, status: :created, location: @company_config }
else
format.html { render action: "new" }
format.json { render json: @@company_config.errors, status: :unprocessable_entity }
end
end
end
我想看看控制器上創建,但不知道如何修改它來滿足我想要什麼去完成。
我的觀點看起來像
<%= simple_form_for(@company_config) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :companyid, collection:build_company_select_array %>
<%= f.input :companyname %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
有太多的信息來回答這個問題。你有什麼嘗試?什麼沒有用?你的觀點是什麼樣子?你的控制器是什麼樣的? – Jesper 2015-03-02 14:38:58
你應該把它標記爲ruby-on-rails,而不是ruby。 – Kris 2015-03-02 15:19:32