ruby-on-rails

Best way to generate javascript code in ruby (RoR)

Hi, I have seen some rails plugins which generate javascript code dynamically using ruby. 1. %Q ( mixed block of javascript and ruby ) 2. <<-CODE some mixed ruby and javascript code CODE Being a java developer I don't understand what those strange looking syntax mean ? Is one way better than the other ? can anyone point me to...

Add style switcher to Rails App admin section?

Hi Everyone, I have been working on a Rails template recently called BaseApp2. You can see it on GitHub here: http://github.com/dannyweb/BaseApp2 There is an administrators section setup which allows the management of Users and I am working on the ability to add announcements to the public site via the admin section. What I would rea...

How do I allow a user to select zero options from a multiple selection box in rails?

I have a settings model with a column options, and set it to serialize with serialize :options. In my view, I have a multiple selection box, using select("settings", "options", ['option1','option2','option3'], {}, :multiple => true) which works fine so long as the user selects at least one option. However, if they don't select any opti...

Running custom SQL to prepare Rails integration test

I am trying to run some custom SQL during the setup of my Rails integration tests to prepare a legacy database (e.g., to create its tables, create any required views, etc.), which is not part of my schema.rb (nor do any migrations for it exist). Are there any best practices for doing so? Googling has not been very enlightening so far ;-...

ActionController::InvalidAuthenticityToken

Today my rails application on remote server suddenly stop working. All errors are in the form Processing UsersController#update (for **ip** at 2010-07-29 10:52:27) [PUT] Parameters: {"commit"=>"Update", "action"=>"update", "_method"=>"put", "authenticity_token"=>"ysiDvO5s7qhJQrnlSR2+f8jF1gxdB7T9I2ydxpRlSSk=", **more parameters**} Act...

In Rails, saving value of type String to a datetime column just saves nil. Why?

I came across this idiosyncrasy while testing my validations. With a migration defined as follows: create_table :time_windows do |t| t.datetime :window_begin, :null => true t.datetime :window_end, :null => true end in irb >> t = TimeWindow.new({:window_begin => Time.now, :window_end => "not a time"}) => #<TimeWindow id: nil, win...

Ruby on Rails - Facebook

Ruby on rails if i submit my create auction form, i want to show in my facebook. how to do that? someone said using OAuth to connect it with my facebook account.. please help me... ...

Follow user- logic

I'm working on Ruby on rails 2.3.8, and I'd like to build a functionality to follow users. For this purpose, I've created 2 tables: users and followings, with their respective models: class User < ActiveRecord::Base has_and_belongs_to_many :followings, :foreign_key => "follower_id" end class Following < ActiveRecord::Base has_and_...

Partial containing a form appears in both controllers, but fails to submit on one of them

I have a partial that contains a form: <% form_for :message, :url => { :action => "create" }, :html => { :id => 'form' } do |f| %> <%= f.error_messages %> <%= f.label :title, "title" %> <%= f.text_field :title %> <%= f.label :tag, "tag" %> <% if controller.controller_name == "tags" %> <%= f.text_field :tag_list, :value =...

Rails ActiveRecord date parsing for i18n (specifically european date formats).

I'm working on a rails project for an Australian website. As a result, they want to be able to enter date formats in the more european-standard of 'dd/mm/yyyy' rather than the US-centric 'mm/dd/yyyy'. I have an ActiveRecord model with a Date field. I'm using jQuery's datepicker to provide the date select on a text field, and have it s...

How complicated can Rails models be? sample projects?

I'm trying to move past the beginner stage of Rails and into the intermediate but I'm finding it hard to find more advanced examples to learn from. For example, I've read that you need to be careful about "Nested Routes" and shouldn't go more than 2 deep. What happens in a situation like this? Customer can place many Orders Orders c...

How do I write a functional test for the update action in a controller?

With actions such as :show and :edit, I can just http GET them. But since the :update action has no template, I can't issue a GET without it complaining about the missing template. That makes sense, so I tried to directly call @controller.update in my test, but I get an error on the respond_to block: NoMethodError: undefined method `p...

acts_as_list postgres error on heroku.

We are using has_many_polymorphs along with acts_as_list. Everything works fine locally, but on heroku, we get an error everytime a couple of acts_as_list methods are called. Namely those that update a number of records with new positions because of an addition or a deletion of an item in the list. Example of acts_as_list method: def ...

Linking a new child with its parent when adding a new child.

I have a customer model that has_many events When I go to the customer show page, I have links to all of the events that are owned by customer. I want to add a "New event for this customer" link. Right now, I'm doing that with <%= link_to "New Event for this Customer", new_event_path %> but when I follow that link, I have to manually ent...

Is Ruby on rails something for me to learn?

I'm mostly a asp.net developer (and currently work as one), but I'm thinking about expanding my skillset or to learn something else. I'm thinking about learning Ruby on rails. What's the pros and cons with these (preferably from a asp.net (mostly version 2.0) perspective). Anyone who has any insights? ...

Couldn't find 'devise_install' generator - Rails 2.3.8, Devise 1.0.8

I'm trying to get Devise up and running with a freshly generated Rails 2.3.8 app. This is the error I'm running into: devise > script/generate devise_install Couldn't find 'devise_install' generator I do have the Devise and Warden gems specified in my config file: config.gem 'warden', :version => '0.10.7' config.gem 'devise', :vers...

How can I force rails to recognize a method's location

I'm having trouble in my application where a controller is calling a method and the server is reporting that the method doesn't exist. This is the method call. The method not working is tag.related_tags @related_tags = @tags.collect { |tag| tag.related_tags }.flatten.uniq The Tag model is originally defined in an plugin acts-as-tagga...

What is the purpose of RakeFile in the application root directory

I am using Ruby on Rails and I see a 'Rakefile' in my application's root directory. What is its purpose and when will it get executed? ...

Possible to annotate just one model in Ruby on Rails?

Working with a large code base and I'm hesitant to run annotate on all models. Is it possible to use the Rails annotate plugin to just annotate one model at a time? ...

request.raw_post trying to pull data from it

def search_results @keyword = request.raw_post @tutors = Tutors.find(:all,:conditions => ["first_name LIKE ?", '%' + "raul" + '%']) end I am trying to get some information out of request.raw_post But it is giving me this long thing authenticity_token=HxxkPMpSr0kHZOVZIYbpMti217BTeUa5G2vX8zbs8ig%3D&keyword=alex&au...