Tag: Rails/フォーム
<%= form_tag(operate_url) do %> <%= submit_tag('移動')%> <%= submit_tag('削除', {name: 'delete'})%> <% end %>
if params[:delete] #削除処理 redirect_to(folder_path(@folder), notice: "削除しました") else #通常処理 redirect_to(folder_path(@folder), notice: "移動しました") end
def make_hash res = [] columns_to_skip = ["created_at", "updated_at", "hash"] for column in Applicant.content_columns next if columns_to_skip.include?(column.name) or self[column.name].nil? or self[column.name].blank? res << self[column.name] end res.hash.to_s end
def create @applicant = Applicant.new(params[:applicant]) a = Applicant.last @previous_applicant_hash = (a.nil?)? 0 : a.applicant_hash if @applicant.valid? unless @applicant.applicant_hash == @previous_applicant_hash @applicant.save ApplicantMailer.admin_notification(@applicant).deliver ApplicantMailer.application_confirmation(@applicant).deliver end redirect_to :action => "success" else render action: "new" end end
Redis.current.lock("#{current_user.id}.action_name") do # Some code end