search for: account_id

Displaying 20 results from an estimated 68 matches for "account_id".

2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give...
2006 Jun 19
3
Using set_primary_key breaks acts_as_tree with non-integer column
...e SQL query as follows: StatementInvalid in PagesController#create -------------------------------------------------------------------------------------- Mysql::Error: #42S22Unknown column ''1_3'' in ''where clause'': SELECT * FROM pages WHERE (parent_id = 1_3 AND account_id = 1) ORDER BY position DESC LIMIT 1 Because parent_id is also now a :string column, the 1_3 should be put into single quotes like so: SELECT * FROM pages WHERE (parent_id = ''1_3'' AND account_id = 1) ORDER BY position DESC LIMIT 1 ... but acts_as_tree assumes that the defa...
2006 Jan 11
3
How do you do a custom sql call in rails?
...need to have a way of generating the next available number for that particular account. I have used a custom sequence table to do this type of thing in the past. The sql I''ve used is the following: begin update customer_number_sequences set current_number = current_number + 1 where account_id = 12345 select current_number from customer_number_sequences where account_id = 12345 commit So my question is how if it all can I integrate this into my @customer.save call??? Should I add a before_create method to the Customer model and do a custom sql call? If so what is the sytax on this...
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is something borked? >> c=Contact.last => #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone: 2147483647, account_id: 8, created_at: "2009-11-27 18:16:25", updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone: false, hide_email: false> >> c.update_attribute(''phone'',8888888888) => true >> c => #<Contact id: 24, name: "Larry", email:...
2010 Dec 02
8
CanCan issue when being very specific
...to do that too. The problem is, I can''t display the Create New User link. It seems everything is correct but I must be doing something wrong. HERE IS ABILITY.RB --------------------------------------------- if user.role == "admin" can :read, User do |u| u.try(:account_id) == user.account_id end can :update, User do |u| u.try(:account_id) == user.account_id end can :destroy, User do |u| u.try(:account_id) == user.account_id end can :create, User --------------------------------------------- HERE IS APP/VIEWS/USER...
2008 Nov 12
5
dynamic condition for has_one and eager loading issue
Hi, I ve defined the following relation in one of my models with a dynamic where condition: has_one :selection, :foreign_key => ''object_id'', :conditions => ''selection_type = 1 and account_id = # {self.send(:account_id)}'' That works perfect, however when I try to eager load that relation I am getting the following error when doing a count. Seems that self is not really my model class anymore.... Does anybody know how I can get that up and running? Thanks a lot in advance NoM...
2007 Dec 04
1
spec''ing shared controller methods
...these methods, not necessarily all the edge cases and I''d like to isolate the examples. This is the approach I''m taking (thanks to bryanl for suggestions and http://pastie.caboo.se/123626). WDYT? This example is a before_filter that finds the Account specified in params[:account_id], which may be used by any number of other controllers in my app. As you can see, the filter is still getting spec''d and has pending examples. ## application.rb class ApplicationController < ActionController::Base ... def find_account @account = Account.find_by_id( para...
2008 Jul 16
2
belongs_to causing endless loop on first call to save!
...aving the data, this issue never arose--another way to put it, those relationships never caused a problem when saving/retrieving already-existing rows. In the model tier, I have the following classes defined: class PrimaryAccount < Account has_many :payment_methods, :foreign_key => "account_id" #using single table inheritance, which is why foreign key is not "primary_account_id" belongs_to :current_payment_method, :class_name => "PaymentMethod", :foreign_key => "current_payment_method_id" #points to same table, so I can have many payment_methods...
2006 Jan 19
4
A simple scaffolding question
All, When I generate scaffolding on my model, it doesn''t display all the fields in the create and edit views. It populates the views with text/char and date types, but omits any integer fields. Is this normal behavior or a bug? Thanks! -Nick
2005 Dec 29
7
belongs_to causing NoMethodError exceptions ... ?
...and account def setup @new = User.new # give it a valid email address @new.email_address = pending_users(:ok_req).email_address @new.password = @new.password_confirmation = ''doesntmatter'' @new.activation_key = ''activationkey'' @new.account_id = pending_users(:ok_req).account_id end def test_create_with_valid_pending_user assert @new.save end end SQL definitions for the tables for the classes involved (postgresql): DROP TABLE generic_users CASCADE; CREATE TABLE generic_users ( password_hash text NOT NULL , email...
2006 Jul 19
2
Creating a safe sequence generator
...to the table, mysql takes care that the jobid is the highest for the given account, and unique as well. The rails way is to create one numeric key for the whole table, and then use a specifically named column for the foreign key: create table jobs ( id int(10) unsigned not null auto_increment account_id int(10) unsigned not null default 0, jobseq int(10) unsigned not null, # not assigned by mysql :( ... other fields ... primary key (id) ); Which is workable, but now the job numbers aren''t specific to the customer, as I would like them to be. In fact, in this model, they are not s...
2009 Jan 28
3
Newbie question about "grouping"
...performing with Syncsort (and have tried in Oracle) with R. I have loaded data in a dataframe and have performed some of the simple aggregations on a subset of data. What I do not see how to do though, is to "group" the aggregations on a particular key value (e.g., sum market_value over account_id). If you can point me in the right direction I'd very much appreciate it. Thanks! John [[alternative HTML version deleted]]
2006 Jan 17
9
using "find" when you have 2 has_many relations
An Account has_many Websites which in turn has_many WebsiteDomains Now I can of course do this: @domains = Account.find(1).websites.find(1).website_domains.find(:all) To get all the domains for Account with id 1 and Website with id 1. I would like to do something like this though: @domains = Account.find(1).websites.find(:all).website_domains.find(:all) IE, get ALL domains for all websites in
2005 Oct 03
2
Explanation of how Scope works?
Hello all, I was wondering if someone could give me a brief explanation of how :scope works. I believe I''ve seen it used with the validation helpers in the past. - Jim
2007 Dec 02
1
total_hits and conditions
...oogled up, but possibly the fix got removed from 0.11.3 to 0.11.4? re = Entry.multi_search(''service'', [Ticket], options, {}) re.size 620 re.total_hits 620 Now add conditions: re = Entry.multi_search(''service'', [Ticket], options, {:conditions => "account_id=#{u.account_id}"}) re.size 5 re.total_hits 620 Looks broken to me. Br, Morten
2009 Aug 04
1
Output XML to File
...by_id(params[:id]) @xml = ::Builder::XmlMarkup.new @unusedtickets = Unusedticket.find(:all, :conditions => [''user_id = ? and updated = true'', @user.id]) end @xml.DocumentElemnts{ for unusedticket in @unusedtickets @xml.unusedtickets do @xml.account_id(unusedticket.account_id) @xml.locator(unusedticket.locator) @xml.ticketnumber(unusedticket.ticketnumber) @xml.traveler(unusedticket.traveler) @xml.issuedate(unusedticket.issuedate) end end } headers["Content-Type"] ||= ''text/xml'...
2012 Sep 02
1
to_model
...nil, sign_in_count: 1, current_sign_in_at: "2011-09-27 17:01:45", last_sign_in_at: "2011-09-27 17:01:45", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2011-09-12 16:55:30", updated_at: "2011-09-27 17:01:45", account_id: 1, role_id: 1, authentication_token: nil> @user.to_model => #<User id: 3, name: "dscdsf", email: "fgd-kX2TDLzHGmnQT0dZR+AlfA@public.gmane.org", encrypted_password: "", phone: "9544443456", address: "fvfdvf", reset_password_token: nil, r...
2006 Jul 03
4
Display find(:include => [:children]) results in a view
I am trying to determine how to display a list returned from a Rails find(:include => [:children]). I am using the following (which works in the console): @patients = Account.find(session[:account_id]).patients.find(:all, :include => [:patient_details]) How can I address the patient_details to display them in the view? The console even shows a @patient_details instance variable being created... Any ideas? =================================== Models: class Account < ActiveRecord...
2006 May 07
4
Paginate() from multiple tables
Hi I''m wondering if there''s a way I can gather data from multiple tables from the child table by using the paginate method? I would have done it using select_by_sql but I need it to paginate. My table structure is: Records is a child of Date and Account Date Account | | ^ ^ Records I want to be able to print a table using the Records controller that will
2007 Jul 09
3
NoMethodError when using find_by_sql
I''m try to verify users on login. Here is my code: def self.authenticate(username,password,account_code) employee = self.find(:all, :select => "e.id, e.first_name, e.last_name, e.username, e.account_id, e.department_id, o.pay_type_id, o.admin_yn, o.payroll_yn, o.files_yn, o.dept_report_yn,e.salt, e.hashed_password", :conditions => ["e.deleted_yn=0 and e.username = ? and a.account_code = ?", username, account_code], :joins => "as e left outer join options o on...