ruby-on-rails

Prioritize fields which start with search term using Sphinx (Thinking Sphinx) - or another full-text search engine.

I'm using sphinx and thinking sphinx to search a customer database. The customer metadata (emails, tels etc) are spread across multiple tables and sphinx indexes all notes on customers etc etc. The problem I'm having is that I want text fields which START with the search term to be displayed first in searches. i.e. a search for "hods" sh...

rails - passing method name to helper function

docs say that options_from_collection_for_select should be used following way: options_from_collection_for_select(collection, value_method, text_method, selected = nil) so, in my case for example options_from_collection_for_select(@messages,'id','title') but i need to put more information to title, so what i tried to do was: class...

Thinking Sphinx, Rails, :has_many :through => ... has

Model: Product has-many product-categories, :through => ... Question 1) How do I index a many to many association with thinking sphinx Must I use has? Questions 2) How is this searched in the controller ex. Product.search params[:search-params], :conditions => {some_conditions} ...

Should I use migrations to create folders?

I created a feature that requires two folders to work correctly. These folders didn't existed in the rails project so I had to create them. Now I need to push this functionality so that the other developers can use it as well. What do you think is the best practice: Create the folders locally and leave a note somewhere explaining that...

error (div class="fieldWithErrors") workaround?

Hello! In my project, I have a register form. My HTML looks like <form method="post" action="/users"> <div style="margin: 0pt; padding: 0pt;"> <input type="hidden" value="lDHrKRC2ENhRKcaoBR4XGfzri/MY09PjqVDvHRtC0D4=" name="authenticity_token"/> </div> <p><label for="login">Login</label> <input type="text" size="30" name...

Resubscribe an email address in Campaign Monitor

Has anyone had success in resubscribing an email address after being unsubscribed via the Campaign Monitor API. I ask as i want to keep a list of Active User's email addresses in my CM Active List. When they are suspended they get removed, when they join or pay their fees before getting deleted they are (re)subscribed. Looking at the R...

Must have Tools for a Ruby on Rails Developer?

What Tools do all you ruby on rails developers use? Also do you use JQuery, Git, Rspec, IDEs etc? What should i stay away from i.e RJS, Prototype, scriptaculous, Sinatra? Any Tips/Tricks/advice greatly appreciated. Thank you in advance ;-) ...

Rails: How do I send an object along with a form?

I have a Post model object that has reference to a parent object. The edit, new and reply methods all use the same partial template. The posts_controller methods: def edit @post = Post.find(params[:id]) end def reply @post = Post.new @replypost = Post.find(params[:id]) @post.title = @replypost.title @post.parent = @replypost...

Trouble with using Fleximage plugin and getting .operate to save changes

I'm using the Fleximage plugin to manage image files in my rails project. This must be dirt simple, but I can't figure it out for the life of me I'm trying to create a thumbnail record. Initially I copy the master image record, and then I try to operate on it to make some changes but the changes are never saved to the database?? I trie...

InvalidAuthenticityToken for JQuery despite setting authenticity token

I'm getting an InvalidAuthenticityToken despite adding in corresponding authenticity tokens in the jquery response. Is there an error in the code, or is there another, root problem? I appreciate any comments. Thanks! Using: Rails 2.3.3, Ruby 1.8.6, Webrick, JQuery 1.3.2 layout/networks.html.haml = token_tag = javascript_tag "window.AU...

Validating a Model Property is Greater than Another

First, let me say I am extremely new to Rails (toyed with it a time or two but forcing myself to write a complete project with it now, started on it yesterday). I am now trying to validate that a model property (terminology?) is greater than another. This appeared to be a perfect instance for validates_numericality_of with the greater_t...

rails habtm relation

Hi I have 2 models which have a has_and_belongs_to_many relation: class Category < ActiveRecord::Base has_and_belongs_to_many :templates end class Template < ActiveRecord::Base has_and_belongs_to_many :categories end I want to know how can I get a category name through this relation, for example I find a first template: t = Tem...

How can I skip email validation with Authlogic in Rails?

I use Authlogic for authentication in my Rails project. It provide default validation for email and login field. But, I want to allow email to be null for join because my service is for mobile and it is difficult to insert email field in mobile device. How can I skip email validation with Authlogic in Rails? ...

Load testing multipart form

I'm trying to load-test a Rails application using JMeter. A critical part of the application involves a form that includes both text inputs and file uploads. It works fine in a browser, but when I try to post that page in JMeter, Rails is saving all of the parts of the multipart form as temp files, which causes things to break when it'...

Recommendations on handling object status fields in rails apps: store versus calculate?

I have a rails app that tracks membership cardholders, and needs to report on a cardholder's status. The status is defined - by business rule - as being either "in good standing," "in arrears," or "canceled," depending on whether the cardholder's most recent invoice has been paid. Invoices are sent 30 days in advance, so a customer who...

Rails collection_select html options.

I can't seem to find the syntax to add a class to a select tag generated by rails collection_select. Some help? ...

Is it possible to make a sinatra application into a Rails engine?

I'm considering using Integrity as a continuous integration tool, but don't want to (or can't) set up a separate domain for the application. Is it possible to get a Sinatra app (like integrity), and make it a Rails Engine? How would one go about do it? EDIT: I realize that the "engines" normally require Rails code like controllers a...

Getting started with the Friendly ORM

I'm following this tutorial: http://friendlyorm.com/ I'm using InstantRails to run MySQL locally. To run Ruby and Rails, I'm using normal Windows installations. When I run Friendly.create_tables! I only get an empty Array returned: => [] and no tables are created in my 'friendly_development' database. Any help on this on one? Thanks!...

Generating XML for ActiveRecord associations using batched find

I have a controller that returns XML for a has_many association in the most straight-forward but inefficient way possible: @atoms = @molecule.atoms.find(:all, :include => :neutrons) render :xml => @atoms.to_xml(:root => 'atoms') This fetches and instantiates all objects at once. To make this more memory efficient I'd like to use Act...

sending emails with ruby where the address has a gmail style '+' filter

When I try and send an email say [email protected] it throws (Net::SMTPSyntaxError) "501 5.1.3 Bad recipient address syntax" is it me or is the syntax checker a little too strict? Has anyone come across this before/have a patch for net/smtp? back trace: /usr/local/lib/ruby/1.8/net/smtp.rb:679:in `check_response' /usr/local/lib/ruby/1....