Passing javascript variables to rails controller

后端 未结 3 1627
予麋鹿
予麋鹿 2020-12-30 09:51

Here is the problem i\'m stuck on. I want to pass the javascript variables to the rails controller.



        
3条回答
  •  旧巷少年郎
    2020-12-30 10:37

    Technically you cant pass variables between two languages.

    You can pass those values to rails controller by appending in url

    
    

    In your controller

    def create
        data = params[:date]
        phone = params[:phone]
        @booking = Booking.new(book_param)
        if @booking.save
            redirect_to root_url
        else
            flash[:notice_booking_failed] = true
            redirect_to root_url
        end
    end
    

    NOTE: Make sure you configure your config/route.rb accordingly

    More Info http://guides.rubyonrails.org/routing.html

提交回复
热议问题