Archive | April 2012

You are browsing the site archives by date.

gem rails not found in “rvm”

Yesterday i got a problem. whil i am trying to open a “rails console” for my new application and i get an error “gem rails not found” i still tried a lot by doing a “bundle install” but neither this help. Then i got a solution. We can select global gemset by using command “rvm […]

Use Draggable marker in gmaps4rails and find current coordinates.

In Rails gmaps4rails it is possible to drag the Marker and get the current co-ordinate by following configuration : <%= gmaps(“markers” => {“data” => @json, “options” => {“draggable” => true}}, “map_options” => { “type” => “HYBRID”, “center_on_user” => true, “processing” => “json”, “auto_zoom” => false, “zoom” => 30, “auto_adjust” => true, “detect_location” => true}) %> […]

Configure SASS PLUGINS path in Rails.

You can configure the  path in the sass pluins rails by setting Sass::Plugin.options You can also check the current loactions of cahce asstes by giving command on rails console as “Sass::Plugin.options” and it print following output in following format : {:cache_location=>”/abc//tmp/sass-cache”, :css_location=>”/abc/public/stylesheets”, :always_update=>false, :quiet=>true, :always_check=>true, :template_location=>”/abc/public/stylesheets/sass”, :full_exception=>true}

Adding Display none to br tag.

Have we ever think in html of adding display:none to br tag?. yes we can add a display:none to br tag by just following this syntax br{ display:none;} 🙂

Sending generated PDF attachments mail in Rails

There are many gems which are used for generating PDF such as “prawn”,”wicked_pdf” and “pdf-kit” but here i show you how we can generate pdf attachement mail using wicked_pdf. mail(:subject => ‘Your Subject’, :to => email, :from => sender_email)  do |format| format.html format.pdf do attachments[“attachement_name.pdf”] = WickedPdf.new.pdf_from_string( render_to_string(:pdf => “receipt”, :template => ‘mailer_view/mailer_action.pdf.erb’) ) end […]

In rails Activerecord sorting fields by specific order

Sometime we need to sort the data neither ascending or nor descending, where we looking for a sorting by particular format. This can be acheive in rails by using simple command @model_object = Model.order(“FIELD(field_name,’string1′,’string2′,’string3′)”) where FIELD is a keyword.

A Rake command not found in “cap deploy”

In Capistrano deployment if you write any rake task to run  and it give error  “rake command not found” you can resolve this issue by just setting up the rake path in deploy.rb as set :rake, “path-of-the-rake-command/rake”