Hi, I want to save with link_to since I keep more attributes with this one.
input
t.string: provecancela
show.html.erb
<%= simple_form_for(@reunion) do |f| %>
<%= f.input
:provecancela,
label: "Por que cancela",
as: :text,
input_html: { :style=> 'resize: none;', size: "5x5", maxlength: 300, title: 'Cancelar' },
placeholder: "Por que cancela"
%>
<%= f.button :submit, "guardar", class: "btn btn-success" %>
<%= link_to 'Cancelar', cancelprov_path(@reunion.id), data: { confirm: 'Está seguro de cancelar' } %>
<% end %>
routes.rb
get 'reuniones/:id/cancelprov' => 'reuniones#cancelprov', as: :cancelprov
meetings_controller.rb
class ReunionesController < ApplicationController
before_action :set_reunion, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource
def index
@q = Reunion.ransack(params[:q])
@reuniones = @q.result(distinct: true).paginate(page: params[:page], per_page: 5)
@reuniones = @q.result.includes(:planta).paginate(page: params[:page], per_page: 5)
end
def cancelprov
r = Reunion.find(params[:id])
r.provecancela #Aqui quiero que guarde el input
r.nombreprovee = User.find(current_user.id).name
r.emailprove2 = User.find(current_user.id).email
r.cancelprov = true
r.save(validate: false)
redirect_to action: "show", id: r.id
end
def show
end
# GET /reuniones/new
def new
Time.zone = 'America/Bogota'
@reunion = Reunion.new(fecha_entrega: Time.zone.now.strftime("%d/%m/%Y"), hora_inicio: Time.zone.now, hora_final: Time.zone.now)
end
# GET /reuniones/1/edit
def edit
end
# POST /reuniones
# POST /reuniones.json
def create
@reunion = Reunion.new(reunion_params)
respond_to do |format|
if @reunion.save
format.html { redirect_to @reunion, notice: 'Reunion was successfully created.' }
format.json { render :show, status: :created, location: @reunion }
else
format.html { render :new }
format.json { render json: @reunion.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /reuniones/1
# PATCH/PUT /reuniones/1.json
def update
respond_to do |format|
if @reunion.update(reunion_params)
format.html { redirect_to @reunion, notice: 'Formación exitosa' }
format.json { render :show, status: :ok, location: @reunion }
else
format.html { render :edit }
format.json { render json: @reunion.errors, status: :unprocessable_entity }
end
end
end
# DELETE /reuniones/1
# DELETE /reuniones/1.json
def destroy
@reunion.destroy
respond_to do |format|
format.html { redirect_to reuniones_url, notice: 'Reunion was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_reunion
@reunion = Reunion.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def reunion_params
params.require(:reunion).permit(:hora_pedido, :fecha_pedido,
:hora_inicio, :hora_final, :fecha_entrega, :observacion, :subtotal,:atencion,
:planta_id, :ubicacion,:hora_entre,:nombre,:puntualidad,:fullid,
:variedad,:presentacion,:reunionfullnombre,:producto_id,:cantidad,:valor,:reunionvalor_id)
.merge( areausolir: current_user.gerencia, emailsoli: current_user.email, nombresoli: current_user.name)
end
end