Hi all,
Is there a way I can know what attributes are updated in my model? I only want to do a validation on a user when a certain attribute was posted. This would actually be the hash that is sent via the params
eg:
@user.update_attributes(params[:user])
Thanks.
...
Those outside of the ruby community (and some inside) oft reference ruby applications as being slow. For many of us this is an irrelevance, IO bound operations etc. However, when it does become a problem there is little to hold us back from taking advantage of native code to speed things up. To this end I am wondering why RoR (itself the...
I have one page in view side of my application where there is a loop of the object @users now i want to update only one part of the div and that div is inside the loop i have made div dinamic but i want to update that div , in the same page. I have used partial page to update the page by controller , but that is not wrking due to div is ...
I'm creating a social network in Rails and I have a model like this:
create_table "friendships", :force => true do |t|
t.integer "user1_id"
t.integer "user2_id"
t.boolean "hasaccepted"
t.datetime "created_at"
t.datetime "updated_at"
end
The problem is that you cannot add yourself as friend, so I tried this in my...
I'm working on this record insert/delete I'm not sure what the syntax is to perform the query.
I have a user model and an event model. I have created a joining table called Personal that stores the user_id, and event_id of any events that the users like.
I created an "Add" method in my events controller so whenever someone clicks it r...
I want to learn some MVC framework. I am trying to learn CakePHP by reading the docs on their website. But I am finding it very difficult to learn it.
Can someone suggest a good way to begin learning CakePHP and provide some alternative websites?
...
Rinari hasn't been updated in the last few months, and there doesn't seem to be such progress made in the branches on github.
I've never tried emacs-rails, but from what I can see, the same applies.
So, is there a rails mode somewhere that's compatible with v3 ?
...
I rely on a counter cache value in an after_create hook of my model. However, my hook is called before the counter cache gets updated, thus breaking a computation.
Is there any way to force a counter cache "flush" so that I always see an up-to-date value in after_create?
...
Given I have a rails app
And I'm using cucumber
And I'm using capybara
And I have an action that results in a redirect_to "http://some.other.domain.com/some_path"
When I test this action
Then the in-app portion of the test works fine
But I see this error: No route matches "/some_path" with {:method=>:get} (ActionController::RoutingError)...
Foreign Direct Investment (% GDP)
2000 2001 2002 2003 2004 2005 2006
Brazil 5.09 4.05 3.28 1.84 2.74 1.7 1.73
China 3.22 3.36 3.39 2.86 2.84 3.44 2.81
India 0.78 1.15 1.11 0.73 0.83 0.94 2.13
Mexico 2.87 4....
I have two tables:
create_table "friendships", :force => true do |t|
t.integer "user1_id"
t.integer "user2_id"
t.boolean "hasaccepted"
t.datetime "created_at"
t.datetime "updated_at"
end
and
create_table "users", :force => true do |t|
t.string "email"
t.string "password"
t.string "phone"
t...
I have a resource defined in routes.rb like so:
map.resources :users
I like using the cleanest link_to option, which would be:
link_to @user
I'd like to add an additional parameter to this call, though: "view=local"
If I were using the user_path, I'd do this:
link_to user_path(@user, { :view => 'local' })
Is there a way to get ...
Hi,
I'm working on a Ruby on Rails (3 beta) project which is basically a simple back-office with users, contents and localizations.
This back-office will be our start for all news projects.
However this base isn't perfect and might be widely improved.
So i would like to keep improving this base during the development of the new proje...
Using Apache2 (2.2.12) / Passenger (2.2.9)..
Have 2 apps running.. One runs fine in production mode the other insists on being in development mode.
Have booted mongrel into production mode and the app works fine.. (script/server -e production)
Tried the following with no result...
Forced the RailsEnv in the apache virtual host.
For...
Hello, How do you think is the more optimum way to retrieve all the attributes for each association that an AR model has?
i.e: let's say we have the model Target.
class Target < ActiveRecord::Base
has_many :countries
has_many :cities
has_many :towns
has_many :colleges
has_many :tags
accepts_nested_attributes_for :countries...
Hello all,
I just did a first time ruby enterprise edition, installed some gems, and now I'm trying to do a
' sudo ./rake gems:install' and getting a:
rake aborted!
No Rakefile found
error. Firstly, what directory should I be doing this from?
Here are the steps I've followed:
download ruby enterprise from http://www.rubyenter...
Consider the following partial, it gets inserted into a page if someone clicks ajax "add comment" link. The question I have is: Is this the best place to include that javascript?
I thought it was best to put it in the application.js, but because the partial gets added via ajax, the validate method called within $(document).ready block ...
I have a rails project with seeds that are executed using rake db:seed. This in turn loads the RB files in the db/seeds directory which in turn executes something like this:
Fixtures.create_fixtures("db/seeds","projects")
There is a projects.yml in the form
project_name1:
property: value
project_name2:
property: value
In the ...
Here's the scoop:
As a learning exercise, I'm trying to write a Rails clone of one of the many location-based games out there (Foursquare, Gowalla, etc.) I have Users who create and check in to Stores.
In ActiveRecord terms:
:user has_many :stores
:store belongs_to :user
But now I've created a third model - Checkins. The table behin...
I'm working on Ruby on rails 2.3.2 and I'd like to keep the search text through postback so I can populate it after that.
Right now, the search page is called by a method called "search" on a controller. Once the search is done I render the file this way:
render :file => '/search/index', :layout => true, :use_full_path => true
I'd li...