ruby-on-rails

actionmailer with gmail in production

I am sending mails using actionmailer and using gmail with the following configuration In Notifier.rb ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, # :domain => I18n.translate('notifier.domain'), :domain => 'gmail.com', :user_name => '[email protected]' :...

I18n for database tables in Rails 3?

How do I create translations to my database table rows? I recall that you in PHP Symfony could have one table with english rows, another with swedish rows. And in your controller you just specify the language you would like to use and your model would use the appropriate table. Is this possible in Rails? Thanks! ...

Ruby: how does running this block through instance_eval work?

I have recently seen some code that I do not completely understand. There is an array named foo that contains instances of Proc objects. Then, an env object is used to setup an environment to work in: env = Object.new foo.each do |f| env.instance_eval &f # what happens here? end What exactly happens when you open the object with i...

Ruby on Rails on IIS7

Due to client requirements, I need to get Ruby on Rails working on IIS7. I'd like to hear recommendations which version of Ruby to choose (IronRuby vs. Ruby) and the best approach for using IIS7 (ISAPI Rewrite, IronRuby.Rack, FastCGI). Also, what is the reliability of the above options. I've never done this on a Windows environment using...

problem with Actionmailer "Timeout::Error" ?

Hi im trying to send a email with action mailer and it gives me a Timeout::Error (execution expired): even though in the console it says that the e mail is sent: it shows Sent mail to [email protected] then displayes the e mail that was sent then it shows the following error: Timeout::Error (execution expired): /usr/lib/ru...

Can't create wildcard mapping for Ruby on IIS7.5

I'm following the steps to run Ruby on Rails on IIS here: http://mvolo.com/blogs/serverside/archive/2007/02/18/10-steps-to-get-Ruby-on-Rails-running-on-Windows-with-IIS-FastCGI.aspx I'm running on Windows 7 64-bit (which I think is IIS7.5) and verified that CGI was already installed. But when I got to step 9, creating the wildcard mappi...

rails way of doing if/else logic

I have following code which seems to work fine: <%if group.employees.count > 0%> <td><%= link_to group.employees.count.to_s, {:action => 'index', :controller => 'employees'}, {:id=>group.id}%></td> <%else%> <td><%= link_to "Add Employee", {:action => 'new', :controller => 'employees'}%></td> <%end%> I'm just wond...

Searching by bitmask in ActiveRecord

I have a users table with a bitmask field that has a permissions mask in it. Locally, I can determine whether a user has a certain permission by doing a bitmask (UserPermissions&Perm)==Perm. However, I want to be able to issue a find_by_mask or something similar, perhaps using a :conditions, but I can't seem to find out how I can query t...

How do I specify associations in Rails that pass through several models

I'm writing some tricky polymorphic relationships to handle tagging. I have a Tag model, and a Tagging model which belongs_to a polymorphic taggable. I have an Item model, which has_many :taggings, :as => :taggable, and has_many :tags, :through => :taggings, so that I can call @item.tags. This is all working ok. I want to bring anoth...

Why should I use Globalize2 for I18n in the database in Ruby on Rails?

I wonder why I would Globalize2 for translating my table columns in Rails. Basically what Globalize2 does is to add a new table for the original one, where you have the locale column and the translated columns. eg. Threads: id, created_at, updated_at Thread_translations: id, thread_id, locale, title, body, created_at, updated_at I w...

Does fetching current_user require a corresponding view?

In my controller i have an action which does not have a corresponding view. Precisely: the upload action for uploading images. However, i require the current users id to store the image url. But the current_user method always returns nil, as the action by itself does not have a view. In such scenarios how do i fetch the current_user? I a...

How to inherit java classes in a Ruby on Rails environment

Background: I have a Java application that many programming clients interface with. Recently, a few clients wanted me to develop an API to allow them to inherit my application's Java classes in their Ruby documents without having to change their developing environment to Jruby - they want it to remain Ruby on Rails. In this post, it wa...

Logical destroy

Hi, i have used some of association in my project model. Corresponding child record will be deleted through dependent :destroy, if i delete any parent record.I have implemented logical delete which means every table has 'active' column by default it is 'true'. every true record is valid all other records are invalid(deleted record). in ...

Geocoding an IP Address in Rails

Hello all, I have GeoKit setup and in general I'm really happy with it. But I recently tried Geocoding IP Addresses with it and its default results (provided by hostip.info it looks like) don't seem very accurate or complete. Has anyone else had bad results from this? Is there a better way to GeoCode IPs in Rails? ...

Rails' validates_confirmation_of

I am trying to create a registration form (just for practice) and saw this method for rails and want to use it. However, I am quite confused on how I should use this. I have fields where each corresponds to an attribute in the database. Like I have text_field_tag(:username) and my model has t.string :username. For password confirmation,...

How to maintain Multiple concurrent user sessions in a rails application?

How to maintain multiple concurrent user sessions in a web application? I am using restful-authentication plugin for user authentication. when, I opened a new browser n log in as a different user, the session of the previous user is being killed. only one user is able to access my application at a time. Please help me out in solving this...

How to import Production Data from Development Database?

Hello. Recently, I learn to develop a rails application. Now, I have a problem. I want to change into Production Mode. But I don't want to copy my data in developement database manually. How should I do these easily? I use mysql and Mac os and rails 3 beta. Tks. ...

custom Tab Builder with tabs_on_rails plugin

I have use tabs_on_rails plugin to do tabs view. and its documentation told me that we can custom a builder to override methods like open_tabs: the method called before the tab set close_tabs: the method called after the tab set tab_for: the method called to create a single tab item the problem is I don't know where to put the overri...

How to configure default paths in Jammit ?

Hi, I have a Jammit gem installed. I want to configure it a little: it must pack all the stuff into "public/assets_cache" folder, so, the packaged stuff will not make clutter in "public/assets", that has all .js and .css files. I have followed documentation here and here environment.rb is: require "Jammit" ... config.gem "jammit" ...

method_missing override is not working

I wrote a convenience ActiveRecord extension to delegate methods to a base object (based on multi-table inheritance) class ActiveRecord::Base def self.acts_as(base) class_eval %Q{ def method_missing(method, *args, ActiveRecord::Base belongs_to :my_object acts_as :my_object end # base class class MyObject < ActiveRecor...