ruby-on-rails

How to completely remove Rspec and its generated files, and reinstall them into a project?

Is it possible to completely remove rspec from a project, and then reinstall it again? The reason I ask is because I had started my project on Rails 3 beta, and now that the new one has come out, the new rspec conflicts and nothing passes. But if I start a new project, everything seems to work as expected. ...

Voting update on Ruby on Rails

Right now, I'm in the middle of building a social media app on Ruby on Rails, i have implemented a 5 point voting system. Where you can vote the news posted on the site from 1-5, what I'd like to know is, What is the best approach at handling the updates on the voting system. In example. If a user already voted in an article I'd like to...

Error while installing an older version of a gem after Sep 1st(Rails 3.0.0 release)

I am on Ruby 1.8.6 and Rails 2.3.8. I am trying to install a older version of formtastic gem. gem install formtastic -v 0.9.10 I got the following error: ERROR: Error installing formtastic: activemodel requires Ruby version >= 1.8.7. I switched to Ruby 1.8.7 and tried to install the gem again. I got the following error: E...

Rails development on Windows

I have been developing Rails applications on windows platform for a couple of month now and I'm still looking for right tools how to do it more effectively. I'm using Netbeans IDE and running all rails commands through windows CMD (including GIT). But NB feels kind a bloated and slow. I have tried using gVim but i did not have so much t...

Partial Layout in Rails 3.0.0

I have a collection of partials being rendered using a layout for each element (wrapping in a container). However, when rendering the collection, an outer 'container' is also added (it appears to be adde to each render, despite no layout being specified. Example: # index.html.erb <%= render :partial => 'sprockets' %> # _sprockets.html...

ActiveRecord OR query

This is an embarrassing noob question, but... How do you do an OR query in Rails 3 ActiveRecord. All the examples I find just have AND queries. Edit: without using a SQL string! ...

search by attribute_like_any using multiple words in one field [searchlogic]

My form <% form_for @search do |f| %> <%= f.input :name_like_any %> ... <% end %> Controller @search = Product.search @search.name_like_any(params[:search][:name_like_any].split(/\s+/)) @products = search.all This returns the correct result, but now my form shows the name as ["foo", "bar"] instead of what the user input ("foo b...

Does scriptaculous come with Ruby on Rails?

I read that prototype does but didn't know if that means scriptaculous does. I looked at the javascript folder and it had prototype, dragdrop, controls, effects, and application. Is that all scriptaculous? Do I just add a link to it in my layout to use it? Also, The scriptaculous website said all sorts of "big names" use it, but I've...

Has anyone tried a multi-domain/multi-database/single-deployment Rails setup?

I'm developing an app (basically an intranet) which has a few small sets of users, each a company using the app internally. Up to now, each set of users has its own deployment with a separate domain name and database, but all living on the same server. This means that each time I have to push an upgrade I need to deploy once per client....

RoR set default value for text field while using observe

Hi, I am trying to set a default value for a text field used for a search, which uses the observe method. Here's what I got which works. <% form_tag('javascript:void(0)') do %> <%= text_field_tag 'phrase', nil, {:onfocus => "$('results').show();", :onblur => "$('results').hide();"} %> <%= observe_field :phrase, :frequency...

Objectiveresource redirect to the current user on a UIView

I'm trying to use ObjectiveResource to make an iPhone app speaking to my Ruby site. I can connect with log/pass, but I would like to have directly the account page on the first screen. I retrieve the name like this : self.title = [ObjectiveResourceConfig getRemoteUser]; But unable to have all informations (always a nill object) when I t...

Security in RESTful Rails controller actions - Should I always use respond_to format block?

Wondering if I should ALWAYS use the respond_to/format.xxx block in ALL of my actions in ALL of my controllers. This came up because I realized that, for apps using only HTML response format (no respond_to block), I could send some other type of request (say XML) and get a valid response. Is this considered insecure? Feels to me like ...

how do you install jquery in Ruby on Rails?

Is it just a matter of installing the jquery.jq file in the javascript folder and linking to it? ...

Ruby: Declarative_authorization polymorphic associations

I have two models (Item and Theme). They are both owned by a third model Users with a has_many association (User has many Themes and Items). Both Item and Theme have_many :images. The Image model is a polymorphic association so the table has the columns imageable_id and imageable_type. If I had both an Item with ID 1 and a Theme with ...

How to start a Rails 3 app with HAML and SASS as the default templates?

the line rails new someapp -m haml doesn't work. It seems to need a path to some where. Update: haml-rails is in fact installed by gem install haml-rails but the line above wouldn't work. ...

How do you tell the Rails version inside of a Rails app?

Up to Rails 2.3.8, there is a constant: RAILS_GEM_VERSION "2.3.8" but Rails 3.0.0 doesn't have it. Is there other ways? ...

Is it possible to have too many validations?

Does the number of validation ClassMethods have anything to do with the performance of an application? Could a boatload of validations cause a strain? ...

Does anyone have experience with Ruby in Steel?

Coming primarily from a .NET background, I am quite attached (for better or worse) to Visual Studio. I'm going to school for software engineering now, though, and my first class is in XP (Extreme Programming) using Ruby on Rails. Mostly I've heard that when you're developing in Ruby, you tend to skip the whole IDE altogether; and I'm to...

Rails 3, Bundler, LoadError

I'm writing an app that will run scripts in a specified folder, and then record the numbers and graph them. My problem is that if the script is a ruby file, the require statements fail inside the script because bundler seems to have done something funky with the load path. Running rails runner Datasource.run_jobs fails: class Datasou...

rake background task can not run

I want to use rake background task in rails like this system("cd #{Rails.root} && RAILS_ENV=#{Rails.env} rake abc:def --trace 2>&1 >> #{Rails.root}/log/rake.log &") This is ok in development environment, but will not work in production mode. I used logger to check whether the command string is generated ok or not, but it seems every ...