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> | |
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
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
(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
# 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
class ItemImage < ActiveRecord::Base | |
belongs_to :item, :polymorphic => true | |
mount_uploader :image, ImageUploader | |
scope :the_cover, where(:cover => true) | |
end | |
class Book < ActiveRecord::Base | |
has_many :item_images, :as => :item | |
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
class String | |
def to_query_params | |
words = [] | |
self.split(/\W/).each do |word| | |
words << "%#{word}%" | |
end | |
return words | |
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
module Mmplus | |
module Models | |
autoload :Items, 'mmplus/models/items.rb' | |
autoload :Askable, 'mmplus/models/askable.rb' | |
autoload :Profile, 'mmplus/models/profile.rb' | |
autoload :ShippingCosts, 'mmplus/models/shipping_costs.rb' | |
autoload :BookshopConstraints, 'mmplus/models/bookshop_constraints.rb' | |
end | |
module Controllers | |
autoload :Search, 'mmplus/controllers/search.rb' |
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
module Mmplus | |
module Controllers | |
module Items | |
extend ActiveSupport::Concern | |
included do | |
before_filter :set_instance | |
def index | |
do_search(params[:search] || {}, @instance) | |
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
class Items::RareBooksController < Items::ItemsController | |
include Mmplus::Controllers::Items | |
end |
OlderNewer