I can't understand why this code works:
@ads = Ads.find(
:all,
:joins => "INNER JOIN ad_users u ON u.ad_users_id=ads.ad_users_id"
)
and this one doesn't:
@ads = Ads.find(
:all,
:joins => :AdUsers
)
my classes are:
class Ads < ActiveRecord::Base
set_primary_key :ads_id
belongs_to :AdUsers
end
and
class AdU...
Hi friends,
I am using the rails 3 for my app ,in that i need to use the proc for named scope but it is not working form me
scope :donate_list,Proc.new {|nonprofit,event| where("zip IN (?) AND category_id IN (?)",nonprofit,event)}
where its getting wrong
...
I am using respond_with and everything is hooked up right to get data correctly. I want to customize the returned json, xml and foobar formats in a DRY way, but I cannot figure out how to do so using the limited :only and :include. These are great when the data is simple, but with complex finds, they fall short of what I want.
Lets say...
I had some problems making libcurl work with C++ JsonCpp library and, after a lot of research, I came up with this code:
int post(const string& call, const string& key, const string& value) {
// (...)
char* char_data=NULL;
struct curl_slist *headers=NULL;
headers = curl_slist_append(headers, "Content-Type: application/json; c...
I am migrating an existing application from Rails 2 to Rails 3. In the old environment file, SqlSessionStore was set up with:
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:database_manager => SqlSessionStore)
SqlSessionStore.session_class = MysqlSession
When trying to start my application in Rails 3, I'm told:
DEPRECA...
Could you tell me how to setup simplecov to test models with rspec and controller with cucumber only?
I don't like it that rspec and cucumber coverage are mixed together...
...
Using Rails 3, I have some models (e.g. Product) in the root namespace, but controllers (e.g. Admin::ProductsController) in an Admin:: module. Unfortunately, this seems to be causing issues with basic functionality, such as form_for(@product) producing
undefined method `products_path' for #<#<Class:0x103dc4110>:0x103dc1618>
This is pr...
Given the following model:
class User < AR::B
has_many :permissions
has_many :projects, :through => :permissions
end
class Project < AR::B
has_many :permissions
has_many :users, :through => :permissions
end
class Role < AR::B
has_many :permissions
end
class Permission < AR::B
belongs_to :user
belongs_to :proje...
Ruby on Rails has many different generators and other such things. In my experience, the naming is hardly ever obvious though for if you should use a singular or plural name.
For instance for the Controller generator you are suppose to use plural
$ rails generate controller Users new
But for Models you are suppose to use singular(for...
This question is really hard for me to describe, so any improvements on it would be nice.
I am currently on Ubuntu 10.4, I have installed RVM (probably as root, that could be my mistake)
I did what this guide told me to do: http://rubyonrails.dreamwidth.org/1713.html and from my point of view it worked.
I was able to create a project ...
I'm trying to run the following migration
def self.up
add_column :users, :perishable_token, :string
User.all.each { |u| u.reset_perishable_token! }
change_column :users, :perishable_token, :string, :null => false
add_index :users, :perishable_token
end
and the u.reset_perishable_token! code behaves strangely (no retur...
I'm upgrading from rails 2.3.8 to 3.0.0, so I need to replace the remote_form_for helper calls with form_for(@object, :remote=>true).
I've been following along with Simone Carletti but I cant seem to get the ajax callbacks from rails.js to fire.
My generated HTML is:
<form accept-charset="UTF-8" action="/vendor_shipments" class="new_v...
I've been using Wordpress for awhile, it's installed on my own server, and one of the features I most love about it is how every time there is a new version it alerts you within the app's web-based admin and with one click I can upgrade the app. I don't have to get anywhere near a console.
Personally I wouldn't mind updating manually, b...
Hi,
In rails 2.x I could pass on a --git option to ./script/generate to add files to git automatically after creation. However I have been unable to find such an option (or configuration) in Rails 3.0.
Has this been removed or am I missing something? I tried researching this for a while but I am unable to find any reference.
Thanks,
P...
Use of rails 3 recaptcha. In view _form.html.erb insert <%= recaptcha_tags %> But when viewing the page in the browser receives
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=**&amp;error=expression&quot;&gt;&lt;/script&gt;
As I understand it is not rendered in the browse...
On my website, in the footer, i want to clearly show which version of the code is live.
I am using git as version control. It would be great to get some visual feedback to know which version is actually live.
I want to show some readable number, like a gem version number. I could create a VERSION file, which i manage and increase every ...
Hi, I am working on a Rails 3 app, and I need to return back a list of players where the sum of points_received per player, is greater than a specified amount.
I have tried this:
Answer.sum(:points_received, :group => 'player_id').having("points_received > 5")
but of course this gives me an error: NoMethodError: undefined method `ha...
I want to write basically
User.find(:all).each {|u| u.update_attribute("email","nil#{incrementing_number}")}
How do I make that #{incrementing_number} incremement per updated attribute.
:D
...
I have a number of models that need the same scope. They each have an expiration_date date field that I want to write a scope against.
To keep things DRY, I'd like to put the scope in a module (in /lib) that I'll extend each model with. However, when I call scope within the module, the method is undefined.
To work around this, I use c...
i have the following 2 classes.
class Customer < ActiveRecord::Base
set_table_name "customer"
set_primary_key "customerId"
has_many :new_orders, :foreign_key => "customerid", :primary_key => "customerId", :class_name => "NewOrder"
end
class NewOrder < ActiveRecord::Base
set_table_name "viewNewOrders"
set_primary_key "orderid"
bel...