Home>

I am creating an event application with ruby ​​on rails.
With that function, if you create an event on the application, you can make it a friend of LINE
I want to make an announcement that an event has been created using LINE Bot.

I saw the LINE Developer site, what should I do?
I am at a loss.
If i have a reference site, please let me know.

Applicable source code

ruby 2.6.3p62
Rails 5.1.7
The development environment is AWS cloud9.
Put event_controller.
I want to send it to LINE when it is saved by create.

before_action :logged_in_user, only: [:new ,:show, :edit, :update, :destroy]
  before_action :correct_user, only: [:edit]
  before_action :admin_user, only: :destroy
  def show
    @event = Event.find(params[:id])
  end
  def index
    @search_events = Event.all.page(params[:page]).search(params[:search])
  end
  def new
    @event = Event.new
  end
  def create
    @event = Event.new(event_params)
    if @event.save
      @event = @event.update(prefecture_search:params[:event][:prefecture])
      flash[:success] ='New event created successfully. '
      redirect_to events_url
    else
      render :new
    end
  end
  def edit
    @event = Event.find(params[:id])
  end
  def update
    @event = Event.find(params[:id])
    if @event.update_attributes(event_params)
      @event = @event.update(prefecture_search:params[:event][:prefecture])
      flash[:success] = "Updated event information."
      redirect_to event_url
    else
      render :edit
    end
  end
  def destroy
    @event = Event.find(params[:id])
    @event.destroy
    flash[:success] = "Data for #{@event.event_day} has been deleted."
    redirect_to events_url
  end
  private
    def event_params
      params.require(:event).permit(:event_day, :start_time, :finish_time, :prefecture, :place, :estimate_people, :level, :organizer_user_id, :organizer_name, :organizer_tel, :comment)
    end
   # Make sure i am a logged-in user.
    def logged_in_user
      unless logged_in?
        store_location
        flash[:danger] = "Please log in."
        redirect_to login_url
      end
    end
    def correct_user
      @user = User.find(params[:user_id])
      redirect_to(root_url) unless @user == current_user
    end
    # Determine if you have the system administration privilege.
    def admin_user
      redirect_to root_url unless current_user.admin?
    end
end
code
What I tried

https://qiita.com/sakakinn/items/e771f3d7732f6bb655d3
I referred to the above site, but I do not know how to create an event and reflect it on LINE.

Supplementary information (FW/tool ​​version, etc.)

Please provide more detailed information here.

  • Answer # 1

        flash[:success] ='New event created successfully. '
          redirect_to events_url

    At a glance, I wonder if I should put in the process to send a message to LINE before redirecting here.