This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lets you call object.rsend('method1.method2.method3') instead of object.send('method1').send('method2).send('method3) | |
class Object | |
def rsend(method, *params) | |
method.to_s.split('.').inject(self) { |obj, mth| obj.send(mth.to_sym, *params) } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in /Users/marchino/Sites/mmplus) | |
en_search /search-results {:i18n_locale=>"en", :method=>:get, :controller=>"items/items", :action=>"search"} | |
it_search /risultati-della-ricerca {:i18n_locale=>"it", :method=>:get, :controller=>"items/items", :action=>"search"} | |
search /search(.:format) {:method=>:get, :action=>"search", :controller=>"items/items"} | |
en_books /books {:i18n_locale=>"en", :controller=>"items/books", :action=>"index"} | |
it_books /books {:i18n_locale=>"it", :controller=>"items/books", :action=>"index"} | |
books /books(.:format) {:controller=>"items/books", :action=>"index" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mmplus/mmplus_users_resolver' | |
class Users::RegistrationsController < Devise::RegistrationsController | |
append_view_path MmplusUsersResolver.new | |
protected | |
def render_with_scope(action, path=self.controller_path) | |
build_nested_attributes if request.get? or resource.errors.empty? | |
super | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I18n_routing/lib/I18n_routing_common.rb | |
# Return the correct translation for given values | |
def self.translation_for(name, type = :resources, option = nil) | |
# First, if an option is given, try to get the translation in the routes scope | |
if option | |
default = "{option}Noi18nRoutingTranslation" | |
t = I18n.t(option, :scope => "routes.#{name}.#{type}", :default => default) | |
return (t == default ? nil : t) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="choose_language"> | |
<% I18n.available_locales.each do |locale| %> | |
<li class="<%=locale.to_s%>"> | |
<a href="http://<%=locale==I18n.default_locale ? 'www' : locale.to_s%>.mydomain.dev/pages/change_locale?url=<%=request.path%>" rel="nofollow"><span>en</span></a> | |
</li> | |
<% end %> | |
</ul> | |
NewerOlder