ruby-on-rails

Authlogic and conditional validation

Hi, is there any possibility to perform conditional validation in authlogic's model User, that uses validation inside acts_as_authentic block depending on some conditions? I'm trying to implement multistep registration form, described in Ryan Bates's railscast 217 with authlogic. ...

Rails: Facebox link if condition is satisfied

I want to display a facebox link when I click on a element when a particular condition is satisfied. I do not want the user to click if the condition is not satisfied. I am doing something like this to achieve it which is pretty ugly <% if x == 5 %> <a id="something" href="http://www.some_weird_link.com" rel="facebox"> <% end %> <...

How do I use hidden_field in a form_for in Ruby on Rails?

I've read this, but I'm new to RoR so I'm having a little trouble understanding it. I'm using a form to create a new request record, and all of the variables that I need to send exist already. Here is the data I need to send (this is in a do loop): :user_id => w[:requesteeID] :requesteeName => current_user.name :requesteeEmail => curren...

Rails 3.0 . How to pass the select box value through link_to

Hi I knew that Rails3 no longer supporting link_to_remote.... instead of that we can modify the link_to method by using different syntax as follows : link_to "Send",{:action =>"send_mail",:question_id =>question.id},:remote => true,:class =>"button small" My problem is, in my view i keep the select box which contains the list of use...

Fail:(TESTMODE) Transactions of this market type cannot be processed on this system

I have created a test account with Authorize.net and am using ActiveMerchant to process credit card payments for a website. What error I always get is Error#*87 - "Transactions of this market type cannot be processed on this system" mentioned in ActiveMerchant documentations. Any suggestions how to resolve this error ? Following is how ...

Looking for a job queue that can run jobs at a specified time

Hi, I'm looking for a job queue that has the following features: Can specify a specific future time for a job to be run Failures are recorded The ability to delete specific jobs from the queue (can live without this one but would be nice) Not MySQL based Works well with Rails So far I've looked at a few such as starling and sparrow ...

Rewrite a SQL query to work on heroku

Hi, How would i rewrite this rails query to run on Heroku (Portegres) @students = Student.find(:all, :conditions =>["(concat(first_name, ' ', last_name) LIKE ?) OR (concat(first_name, ' ', middle_names, ' ', last_name) LIKE ?)", "%#{params[:search]}%"...

Talking with a SOAP service using Savon gem in Ruby

I'm trying to communicate with a soap service and I know that I should send a SOAP Envelope like this: POST /webpay_test/SveaWebPay.asmx HTTP/1.1 Host: webservices.sveaekonomi.se Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "https://webservices.sveaekonomi.se/webpay/CreateOrder" <?xml version="1.0" encoding...

Is it possible to validate that the title of a new post is not equal to an existing permalink?

In this simplified scenario, I have a model called Post Each post has a title and a permalink The permalink is used in the url - i.e. http://mysite.com/blog/permalink Before a post is created, a callback sets the permalink to be the same as the title I validate the uniqueness of each title but I do not explicitly validate the uniquen...

Rubyamf with attachment_fu problem.

This my class test. has_attachment :storage => :file_system, :max_size => 1.megabytes Rubyamf_config.rb ClassMappings.register( :actionscript => 'TestVO', :ruby => 'Test', :type => 'active_record', :methods => ["created_at","has_attachment"], :attributes => ["id","document_uri", "lock_version"]...

Shoulda rspec matchers :on => :create

I am using some of the Shoulda rspec matchers to the test my model, one of them being: describe Issue do it { should_not allow_value("test").for(:priority) } end My problem with this is that my validation in my model looks like this: validates_format_of :priority, :with => /^(Low|Normal|High|Urgent)$/, :on => :update So when runn...

create an index without locking the DB

I have a table with 10+ million rows. I need to create an index on a single column, however, the index takes so long to create that I get locks against the table. It may be important to note that the index is being created as part of a 'rake db:migrate' step... I'm not adverse to creating the index manually if that will work. UPDATE: ...

Delayed Jobs leaking memory?

I'm using collectiveidea's delayed_job with my Ruby on Rails app (v2.3.8), and running about 40 background jobs with it on an 8GB RAM Slicehost machine (Ubuntu 10.04 LTS, Apache 2). Let's say I ssh into my server with no workers running. When I do free -m, I'm see I'm generally using about 1GB of RAM out of 8. Then after starting the w...

Ruby routes and link_to, custom :action route problem

Hello, I'm trying to get this link: <%= link_to('Edit', :action => 'manage', :id => user) %> even tried explicitly <%= link_to('Edit', {:controller => 'users', :action => 'manage', :id => user}, :method => :get) %> to show the link in HTML as '/users/manage/1' or '/users/1/manage' but it shows up as '/users/manage?id=1' I ca...

Return ActiveRecord query as variable, not hash?

I am doing an ActiveRecord find on a model as such @foo = MyModel.find(:all, :select => 'year') As you can see, I only need the year column from this, so my ideal output would be ["2008", "2009", "2010"] Instead, though, I get an a hash of the models, with each one containing the year, as such: [#<MyModel year: "2008">, #<MyModel ...

Where is the best place to extend the functionality of built in classes in Rails?

I have a few methods I am adding to Ruby's Array class for my Rails application. Where is the best place to put them? Right now I have them in config/environment.rb. ...

SVG files in Raphael, can they be used?

I have an SVG file that I would like to display via Raphael (each svg file is a node in a tree I'm trying to draw, the actual connections of the tree will be made by raphael). I tried something like: var vector_image = paper.image("test.svg", 50,50,50,50); but no dice, seems only "real" image files like png or jpeg are accepted? I fi...

Rails how to programatically get html id from form

Say I have a Rails form like the following <% form_for @model do |f| %> <%= f.label :column %> <%= f.check_box :column %> <% end %> Is there a way I can get the html id that will be generated for the 'column' check box? What would be great is if there was a way to add in <%= f.observe_field :column, options %> Anyone know...

Ruby on Rails: The stringex gem: Problem.

So, i'm using stringex to convert non roman characters, to their roman pronunciation equivalent... for example, it will change 日本語 to nihongo.... And I'm using these as URLs... and when the URLs aren't using the roman alphabet, ruby breaks. Now... this works on my machine... but not on a co-worker's machine... we both have stringex 1.1...

Is Python (Django) experience professionaly comparable to Ruby on Rails?

I ask this because there seems to be a few more jobs available (at least by telecommute) in RoR. If an employer sees significant Python/Django experience on a resume, would it be plausible to believe that the developer would be able quickly learn Rails? ...