2013-09-10 44 views
0

我在丟失似乎並不能爲這個地方找到一個解決方案前添加一個字符串...Rails的 - 在一個形式參數

所有我想要做的是能增加一點問候中我的用戶名前面時,他們提出通過外部API形式...所以沒有什麼是被保存到我的數據庫

ALL我希望能夠做的是

"Web inquiry from Jon Doe" 

,所以我有一個表格

<%= text_field :subject %> 

當用戶將自己的名字爲它並提交表單我的客戶可以去哪裏它被張貼在外部網站,並看到

"Web inquiry from Jon Doe" 

所以我只需要能夠釘在

Web inquiry from 

部分以表格上的名字?

請幫我...你我唯一的希望

我的繼承人控制器

class Website::ContactsController < Website::WebsiteApplicationController 
    def new 
    @contacts = Form.new 
    end 

    def create 
    @contacts = Form.new(params[:contacts]) 
    @contacts.post_tickets(params[:contacts]) 
    if @contacts.valid? 
     flash[:success] = "Message sent! Thank you for conacting us." 
     redirect_to new_contact_path 
    else 
     flash[:alert] = "Please fill in the required fields" 
     render action: 'new' 
    end 
    end 
end 

我的繼承人形式

= form_for(:contacts, url: contacts_path) do |f| 
    = f.error_messages 
    = f.label :subject, "Name" 
    %span{style: 'color: red'} * 
    = f.text_field :subject, class: "text_field width_100_percent" 
    %br 
    %br  
    = f.label "Email" 
    %span{style: 'color: red'} * 
    %br  
    = f.email_field :email, class: "text_field width_100_percent" 
    %br 
    %br 
    = f.label "Phone" 
    %br  
    = f.text_field :custom_field_phone_number_28445, name: 'contacts[custom_field][phone_number_28445]', class: "text_field width_100_percent" 
    %br 
    %br 
    = f.label "Company" 
    %br  
    = f.text_field :custom_field_company_28445, name: 'contacts[custom_field][company_28445]', class: "text_field width_100_percent" 
    %br 
    %br 
    = f.label "Question(s), and/or feedback" 
    %span{style: 'color: red'} * 
    %br 
    = f.text_area :description, class: "text_field width_100_percent", style: 'height: 100px;' 
    %br 
    %br 
    = f.submit "Submit", class: 'btn btn-warning' 

回答

0

這是不是就夠了?

message = "Web inquiry from " + params[:subject] 
+0

即時通訊對不起,即時通訊新的....我怎麼用這個?我會把它放在控制器還是modeL? – user1502223

+0

可能在視圖中顯示的位置。 – tadman

+0

= f.text_field:subject,message =「網絡查詢來自」+ params [:subject] .....那樣? – user1502223

相關問題