configures responders gem [#5]
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -32,6 +32,8 @@ gem 'sdoc', '~> 0.4.0', group: :doc
|
|||||||
# Use Capistrano for deployment
|
# Use Capistrano for deployment
|
||||||
# gem 'capistrano-rails', group: :development
|
# gem 'capistrano-rails', group: :development
|
||||||
|
|
||||||
|
gem "responders"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
gem 'byebug'
|
gem 'byebug'
|
||||||
|
|||||||
18
Gemfile.lock
18
Gemfile.lock
@@ -42,6 +42,12 @@ GEM
|
|||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
byebug (5.0.0)
|
byebug (5.0.0)
|
||||||
columnize (= 0.9.0)
|
columnize (= 0.9.0)
|
||||||
|
capybara (2.4.4)
|
||||||
|
mime-types (>= 1.16)
|
||||||
|
nokogiri (>= 1.3.3)
|
||||||
|
rack (>= 1.0.0)
|
||||||
|
rack-test (>= 0.5.4)
|
||||||
|
xpath (~> 2.0)
|
||||||
coffee-rails (4.1.0)
|
coffee-rails (4.1.0)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (>= 4.0.0, < 5.0)
|
railties (>= 4.0.0, < 5.0)
|
||||||
@@ -54,6 +60,11 @@ GEM
|
|||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.5.2)
|
execjs (2.5.2)
|
||||||
|
factory_girl (4.5.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
|
factory_girl_rails (4.5.0)
|
||||||
|
factory_girl (~> 4.5.0)
|
||||||
|
railties (>= 3.0.0)
|
||||||
globalid (0.3.5)
|
globalid (0.3.5)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
@@ -104,6 +115,8 @@ GEM
|
|||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
rake (10.4.2)
|
rake (10.4.2)
|
||||||
rdoc (4.2.0)
|
rdoc (4.2.0)
|
||||||
|
responders (2.1.0)
|
||||||
|
railties (>= 4.2.0, < 5)
|
||||||
rspec-core (3.3.1)
|
rspec-core (3.3.1)
|
||||||
rspec-support (~> 3.3.0)
|
rspec-support (~> 3.3.0)
|
||||||
rspec-expectations (3.3.0)
|
rspec-expectations (3.3.0)
|
||||||
@@ -154,16 +167,21 @@ GEM
|
|||||||
binding_of_caller (>= 0.7.2)
|
binding_of_caller (>= 0.7.2)
|
||||||
railties (>= 4.0)
|
railties (>= 4.0)
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
|
xpath (2.0.0)
|
||||||
|
nokogiri (~> 1.3)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
byebug
|
byebug
|
||||||
|
capybara
|
||||||
coffee-rails (~> 4.1.0)
|
coffee-rails (~> 4.1.0)
|
||||||
|
factory_girl_rails
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
rails (= 4.2.3)
|
rails (= 4.2.3)
|
||||||
|
responders
|
||||||
rspec-rails (~> 3.0)
|
rspec-rails (~> 3.0)
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
sdoc (~> 0.4.0)
|
sdoc (~> 0.4.0)
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
|
require "application_responder"
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
self.responder = ApplicationResponder
|
||||||
|
respond_to :html
|
||||||
|
|
||||||
# Prevent CSRF attacks by raising an exception.
|
# Prevent CSRF attacks by raising an exception.
|
||||||
# For APIs, you may want to use :null_session instead.
|
# For APIs, you may want to use :null_session instead.
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|||||||
12
config/locales/responders.en.yml
Normal file
12
config/locales/responders.en.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
en:
|
||||||
|
flash:
|
||||||
|
actions:
|
||||||
|
create:
|
||||||
|
notice: '%{resource_name} was successfully created.'
|
||||||
|
# alert: '%{resource_name} could not be created.'
|
||||||
|
update:
|
||||||
|
notice: '%{resource_name} was successfully updated.'
|
||||||
|
# alert: '%{resource_name} could not be updated.'
|
||||||
|
destroy:
|
||||||
|
notice: '%{resource_name} was successfully destroyed.'
|
||||||
|
alert: '%{resource_name} could not be destroyed.'
|
||||||
10
config/locales/responders.es.yml
Normal file
10
config/locales/responders.es.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
es:
|
||||||
|
flash:
|
||||||
|
actions:
|
||||||
|
create:
|
||||||
|
notice: "%{resource_name} creado correctamente."
|
||||||
|
update:
|
||||||
|
notice: "%{resource_name} actualizado correctamente."
|
||||||
|
destroy:
|
||||||
|
notice: "%{resource_name} borrado correctamente."
|
||||||
|
alert: "%{resource_name} no ha podido ser borrado."
|
||||||
8
lib/application_responder.rb
Normal file
8
lib/application_responder.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class ApplicationResponder < ActionController::Responder
|
||||||
|
include Responders::FlashResponder
|
||||||
|
include Responders::HttpCacheResponder
|
||||||
|
|
||||||
|
# Redirects resources to the collection path (index action) instead
|
||||||
|
# of the resource path (show action) for POST/PUT/DELETE requests.
|
||||||
|
# include Responders::CollectionResponder
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user