rails লেবেলটি সহ পোস্টগুলি দেখানো হচ্ছে৷ সকল পোস্ট দেখান
rails লেবেলটি সহ পোস্টগুলি দেখানো হচ্ছে৷ সকল পোস্ট দেখান

রবিবার, ২৭ জুন, ২০১০

undefined method `deep_symbolize_keys' for

check you locale files if the parent locale is there.

for example in en.yml file, it may have en: as fist active text

undefined method `each' for false:FalseClass

if you get this type message and cant find the error location then there could be some reasons behind it.
This is one of them.

just review the locale files you have used, if it meets the yml syntax.
Or
take backup of original local files
create new rails app.
copy en.yml to yours application's locales dir.

if application runs then there must me errors in yml file. try to fix it.

cheers.

সোমবার, ২৮ ডিসেম্বর, ২০০৯

redirect back in rails

The back button is most commonly used button in web browser.
but it becomes pain to developers very often specially when forms are submitted (in post method)

A back button in web page is useful rather using the browser back button:

here is a simple tip for using back button in web page:

#in appplication_controller.rb (for earlier version application.rb )
before_filter :store_location


private:

def store_location
session[:return_to] = request.env['HTTP_REFERER']
session[:previous_request_method] = request.method
#to avoid redirect to post url
end



#in application_helper.rb

def link_to_back_or_default_path(*args)
text = args.first || 'Back'
default_path = args.second || default_path
#default_path can be root_path or any other fixed path
html_options = args.third
if session[:previous_request_method].to_s =='post' || session[:return_to] == ''
redirect_path = default_path
else
redirect_path = session[:return_to]
end
link_to(text, redirect_path, html_options)
end

#in view

<%=link_to_back_or_default_path('back', 'http://boo.com', :class=>'foo, :id=>'bar')%>

or simply
<%=link_to_back_or_default_path%>


Share your thoughts