Answer the question
In order to leave comments, you need to log in
How to make a form work in rails with mongoid?
I'm trying to call back but something doesn't work:
Ruby 2.3.3
Rails 4.2
mongoid 5.2.1
haml
Gemfile
source 'https://rubygems.org'
ruby '2.3.3'
# core
gem 'rails', '4.2.0'
gem 'sass-rails'
gem 'sprockets'
gem 'compass-rails'
gem 'mongoid'
gem 'delayed_job_mongoid'
gem 'newrelic_rpm'
gem 'devise'
gem 'responders'
gem 'puma'
# front end & layouts
# gem 'bootstrap', '~> 4.0.0.alpha5'
# gem 'tether-rails'
gem 'bootstrap-sass'
gem 'turbolinks'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'therubyracer'
gem 'money-rails'
gem "font-awesome-rails"
gem 'nested_form'
gem 'haml'
gem 'dropzonejs-rails'
# gem 'twitter-bootstrap-rails'
gem 'sanitize'
gem 'russian'
gem 'ckeditor', github: 'galetahub/ckeditor'
gem 'chosen-rails'
# gem 'galetahub-simple_captcha', require: 'simple_captcha'
gem 'simple_captcha', :git => 'git://github.com/Azdaroth/simple-captcha.git', :branch => 'rails-4'
gem "letter_opener"
gem 'kaminari'
gem 'kaminari-i18n'
gem 'kaminari-mongoid'
gem 'bootstrap-kaminari-views'
gem 'toastr-rails'
# uploader
gem 'mini_magick'
gem 'unicode_utils'
gem 'carrierwave'
gem 'carrierwave-mongoid'
class Callback
include Mongoid::Document
field :name, :type => String
field :email, :type => String
field :phone, :type => Integer
field :comment, :type => String
end
class CallbacksController < ApplicationController
def new
@callback = Callback.new
end
def create
@callback = Callback.new(callback_params)
if @callback.save
redirect_to (session[:return_to] || :back), notice: 'Спасибо за заявку! Наши менеджеры скоро свяжутся с вами.'
else
render action: 'new'
end
end
private
def callback_params
params.require(:callback).permit(:name, :email, :phone, :comment)
end
end
get '/callback' => 'callbacks#new', as: :custom_callbaks
post '/callback' => 'callbacks#create', as: :custom_callbaks_create
.callback
%a.call{:href => "#openModal"} Заказать звонок
#openModal.modal
.modal-dialog
.modal-content
.modal-header
%h3.modal-title Заказать звонок
%a.close{:href => "#close", :title => "Close"} ×
.modal-body
= form_for :callback, url: custom_callbaks_path do |f|
.wrap-call
.col-call
= f.label 'Ваше имя*'
= f.text_field :name, required: true
.col-call
= f.label 'E-mail'
= f.text_field :email
.col-call
= f.label 'Телефон *'
= f.text_field :phone, required: true
.col-call
= f.label 'Комментарий', for: :comment
= f.text_area :comment, id: 'comment'
.col-call
= f.submit 'Оформить заявку'
http://i.prntscr.com/3riiXKqLShukWfzeAJbi6A.png
http://i.prntscr.com/JI2u2KfES92a8ogj_yo65Q.png
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question