ruby-on-rails

Rails: searchlogic search with or conditions

Hello, I'm using the 'binarylogic-searchlogic' gem in version 2.3.5 along with Rails 2.3.4. What I want to do is performing a search on a model for a specified value over multiple attributes. I achieve this through chaining everything together like User.first_name_or_last_name_or_email_like(value) But with more and more attributes ...

How can I spec out an authlogic sessions controller using using a stub?

I want to test my User Session Controller testing that a user session is first built then saved. My UserSession class looks like this: class UserSession < Authlogic::Session::Base end The create method of my UserSessionsController looks like this: def create @user_session = UserSession.new(params[:user_session]) if @user_sess...

Saving files using Paperclip without upload

Hi, I had a quick question. Is it possible to save a file without actually uploading it through a form? For example, lets say i'm looking at attachments from emails, and i want to save them using paperclip. How do i do this? Do i manually have to call a save_file(or something similar) somewhere? Any help would be much appreciated! ...

What's the difference between :new, :collection and :member routes?

I've read the documentation, but I'm still not sure I understand everything. Especially why there's a :new parameter. As far as I understand, it could be replaced with the :collection parameter. So what's the difference between those three types of routes? ...

Rails - Namespacing models

Usually there are a lot of models in a Ruby on Rails project, so: Is it a good practice to namespace them (in modules/folders)? What are the downsides? EG: Shop category.rb details.rb Products category.rb base.rb etc (instead of ShopCategory, to have Shop::Category?) Should also the controllers be namespaced in the same man...

mysql gem install fails on snow leopard. My computer is 32bit (mac mini core duo)

My end goal is local development of a Radiant CMS installation. So, need rails and a db to play nice. Previous frustrations with mysql led me to try mamp. I have installed MAMP. It is working. I am open to other avenues though. Tried to install the mysql gem but got no love. john-breedloves-mac-mini-2:~ john_breedlove$ sudo gem install...

Rails CMS for a multilingual site

A client wants a multilingual site with a CMS. Is there a Ruby on Rails CMS out there that can deal with that out-of-ze-box? ...

Array to XML -- Rails

I have a multi-dimensional array that I'd like to use for building an xml output. The array is storing a csv import. Where people[0][...] are the column names that will become the xml tags, and the people[...>0][...] are the values. For instance, array contains: people[0][0] => first-name people[0][1] => last-name people[1][0] => Bob p...

RoR - Rendering nested errors on XML

Good afternoon, I'm trying to render as XML the complete ActiveRecord error list, problem is when you do something like: respond_to do |format| format.xml { render :xml => @object } end It does not render nested attributes if you don't say so, so either: you should create a template or calling explicity to_xml method and using ":i...

NOT LIKE not working in MySQL with Rails

>> Comment.count SQL (0.3ms) SELECT count(*) AS count_all FROM `comments` => 451 >> Comment.count(:conditions => ["author_website not like ?",'aaaa']) SQL (1.4ms) SELECT count(*) AS count_all FROM `comments` WHERE (author_website not like 'aaaa') => 203 >> Comment.count(:conditions => ["author_website like ?",'aaaa']) SQL (1....

Handling international currency input in Ruby on Rails

I have an application that handles currency inputs. However, if you're in the US, you might enter a number as 12,345.67; in France, it might be 12.345,67. Is there an easy way, in Rails, to adapt the currency entry to a locale? Note that I'm not looking for display of the currency (ala number_to_currency), I'm looking to deal with some...

What is the best ruby on rails login and authentication plugin

the restful authentication plugin does appear to be broken with rails (2.3.4) [name error and yes I know about the bug that is on hold]. Is their a better plugin/gem? ...

Help with rails content filtering

Im creating my own blog managing app in rails (for experimental purposes).... What would the best way to get this done? I have posts and categories. I want to have a dropdown of categories for the user to select one when they create a new post. Now, each user will have different privileges so not all categories should appear for all user...

rails .jr.erb templates

Experiencing jquery in rails through .js.erb templates; but completely puzzled by a simple problem : for some reason, when a certain controller's action is called, it is recalled like two or three times. and on top of that, the number of recalls to the same action increase as the page is used. so i quickly end up with long loops over the...

Convert a Ruby on Rails app from sqlite to MySQL?

I made an app in Ruby on Rails and now I want to get it hosted. However, they require that I use MySQL and I set it up using sqLite3. Is there any way to convert it to use MySQL? ...

How can I develop Rails alongside a XAMPP installation?

On my work machine, I do PHP development under XAMPP, which includes Apache and MySQL. I'd like to start developing and testing some Rails code on the same machine - also using MySQL (and I assume it also needs Apache). What's the easiest way to do this without conflicts? ...

What is is the best way to manage edit/destroy/new links with authentication?

I'm new to Rails and I'm trying to create a standard CRUD rails application for displaying text posts. It's pretty similar to blog where I would like authenticated users to be able to edit and destroy posts while visitors to the site can just see and browse the existing posts. I would like to know what is the best way to manage this. So...

should redirect to not working

redirect_to is failing for me in my cucumber tests. The step_definition method is Then /^I should be redirected to "(.*)"$/ do |url| response.should redirect_to(url) end In Rails 2.3.3 I'm doing: redirect_to some_url, :status => 301 and return false I'm running that from the application_controller.rb and returning false. When I...

Shoulda + FactoryGirl: Can I make my tests faster?

I'm looking for a way to speed up my Shoulda + FactoryGirl tests. The model I'm trying to test (StudentExam) has associations to other models. These associated objects must exist before I can create a StudentExam. For that reason, they are created in setup. However, one of our models (School) takes significant time to create. Becaus...

activescaffold controller missing activescaffold work around

Hi All, I have a 3yr old application that has some controllers with some very unrestful actions. I'm trying to implement a new resource that has relationships to some of the older ones, but I want to use activescaffold to manage the nested resources rather than try to rewrite the plate of spaghetti that is the rest of the codebase. I ...