ruby-on-rails

How can I use from names in ActionMailer? [Rails 2.3.5]

I want to show a pretty name in the e-mail clients ...

Opening and decompressing an XML URL in Rails

I'm building a rails app that takes information about products from an XML datafeed hosted on a 3rd party server. This XML is sent gzipped, and I'm having serious difficulty in getting anywhere with it. I've spent a fair bit of time with Google on this, but the results of my searching seem to be more about Sending Gzipped output rather ...

[Rails 3] Failed to get session options?

Hi everybody, I'm trying to switch the session store in Rails 3 by changing the config/application.rb as following: config/application.rb #----------------------------------- memcache_options = { :compression => true, :debug => false, :namespace => "xx-cache", :readonly => false, :urlencode => false } CACHE = MemCach...

Rails - ACL9 caching in session

Hey, I implemented authentication with Authlogic and authorization with Acl9. Now I'm trying to avoid multiple hits to database to check if user is admin by keeping this in the session. What I thought is that this code should work: class ApplicationController < ActionController::Base ... helper_method :current_user_session, :curre...

calculate number of working days on a rails form

I have two fields, 'from_date' and 'to_date' on my rails form. When a user enters the dates I have to display the number of working days i.e, exclude (sat, sun and a list of other official holidays in a database table). Is this something that should be done in the client side javascript Or is this something that should be done by maki...

Passing arguments to scope_procedure in searchlogic

I'd like to use searchlogic's scope_procedure feature like so class MyModelObject < ActiveRecord::Base scope_procedure :my_scope_proc, lambda { |p1, p2| { :conditions => "p1 >= #{p1} AND p2 < #{p2}" }} end Then, I am doing the search: scope = MyModelObject.search(:my_scope_proc => true) scope.all The above code obviously doesn't...

tabindex not working on rails form

Hi, I am specifying a tabindex on a rails form. Below is example code for a select input and text input. <div class="row"> <%= f.label :hrs, "Enter number of hours" %> <%= f.select :hrs, VALID_HOURS::HOURS, {:selected => "8"}, {:tabindex => "3", :style =>'width:50px;', :class => "select"} %> </div> <div class="row"> <%= f.label ...

XML testing in Rails - Fixed attributes order in Builder::XmlMarkup in ruby -

I have the following test in my Rails Application: it "should validate xml" do builder = Builder::XmlMarkup.new builder.server(:name => "myServer", :ip => "192.168.1.1").should == "<server name=\"myServer\" ip=\"192.168.1.1\"/>" end The problem is that this test passes sometimes, because the order of the xml tag attributes is unpr...

How to make ./script/generate create RSpecs instead of ActionController::TestCases?

When I run ./script/generate scaffold Whatever, it creates ActionController::TestCase tests for me, but I prefer to use RSpec. Is there any way to get it to generate some default RSpecs for my new class instead? ...

Trouble with authlogic_rpx

Hi, I'm trying to run http://github.com/tardate/rails-authlogic-rpx-sample (only rails version was changed) but get error message http://gist.github.com/385696, when RPX returns information after successful authentication via Google Account. What is wrong here? And how I can fix it? The code was successfully tested with rails 2.3.3 by i...

Is there any way to tell which gems and plugins are loaded at runtime for a Rails process?

Is there any command either in debugger or ruby-debug to get a list of all gems and/or plugins loaded in memory for a Rails process? I understand only the 'require' gems are loaded but I would like to quickly see what got loaded during runtime. ...

Simple rails routing / url question

I'm using Ryan Bates' nifty authentication in my application for user signup and login. Each user has_many :widgets, but I'd like to allow users to browse other users' widgets. I'm thinking that a url scheme like /username/widgets/widget_id would make a lot of sense--it would keep all widget-related code in the same place (the widgets ...

Error installing geoip_city gem

I keep getting an error when trying to install the geoip_city gem. I've already installed the GeoIP C library to /opt/GeoIP, but the gem doesn't seem to pick it up. I've tried: sudo gem install geoip_city -- --with-geoip-dir=/opt/GeoIP sudo gem install geoip_city -- --with-geoip-lib=/opt/GeoIP/lib sudo gem install geoip_city -- --wi...

Memcached: providing TTL setting while connection creation.

I want to set the TTL for the keys while creating the connection. Right now I am setting it while writing to the cache. Is there a configuration parameter for this? ...

using Control.tabs for prototype.js in Rails

Hey everyone, I've been trying to use http://livepipe.net/control/tabs to get some javascript tabs up and running on my rails up. I'm really just trying to figure out how to install this... and I don't see how I'm running into any issues at all. Here are the steps I've taken: put tabs.js in my scripts folder made sure the layout is...

How to log into a salesforce.com sandbox?

I took over a Rails app and am trying to get the Salesforce.com API credentials set up for my user account. I'm set as a system admin with "Developer Mode" on (though I have no clue what that does, I just saw it set on the previous account.) We have a sandbox. I click the login link on it, enter my sandbox username ([email protected]...

Multiple robots.txt for subdomains in rails

I have a site with multiple subdomains and I want the named subdomains robots.txt to be different from the www one. I tried to use .htaccess, but the FastCGI doesn't look at it. So, I was trying to set up routes, but it doesn't seem that you can't do a direct rewrite since every routes needs a controller: map.connect '/robots.txt', :c...

Generate .sql files using rake task

Hi, I have a table called 'choices' in this table i am storing static data for my site like Blood Groups , qualification, job types etc., I have to create rake tasks one is for to create backup choices.sql file from choices table data, second one is dump the data from .sql file to choice table. How can I create the rake tasks. Any ot...

Checking for nil in view in Ruby on Rails

I've been working with Rails for a while now and one thing I find myself constantly doing is checking to see if some attribute or object is nil in my view code before I display it. I'm starting to wonder if this is always the best idea. My rationale so far has been that since my application(s) rely on user input unexpected things can oc...

in ruby, how do you make this nested hash work?

this one creates an error: @settings = { :tab1 => { :name => { :required => true }, :description } } need to change :descrpition to :description => {}, but i don't have any values for :description so i want it to remain as is (without the empty => {}) Would you show me the best way to handle th...