Displaying 20 results from an estimated 1000 matches similar to: "Find Returning String Instead of Integer?"
2007 Aug 03
0
acts_as_paranoid and Association Extensions (has_one troubles)
Hi... Isn''t there a proper way or hack/workaround for the following?
* For the example with unfortunate disabilities.. look below,,,
Usage of has_* (associationmethods) do {def with_deleted
AccociatedModel#with_scope} {Paranoid''s#find_with_deleted}...
The has_one associations give me a nil object when invoking it with
Model.association_OBJECT.with_deleted. Has_many does like
2006 Apr 10
1
random | in join statement with more than one :include
I have an ActiveRecord class that has several has_many,belongs_to,
habtm, and the new has_many => :through relationships.
Whenever I try a
find(:all, :conditions => "some conds", :include [:relationship])
it works fine, but if I have
find(:all, :conditions => "some conds", :include [:relationship,
:other_relation])
it gets a sql error such as
Mysql::Error: You
2011 Nov 18
1
What does :count actually mean in assert_select?
Hi guys,
I tried reading up the RSPEC Book (Dec 2010) and googled a bit but I
could not find anything.
I''m using Rspec2.
Example:
spec/factories/categories.rb
======================
FactoryGirl.define do
factory :category_intakes, :class => ''category'' do
name ''intakes and filters''
description ''airfilters and
2006 Jan 20
11
Userstamp Plugin
I''m pleased to announce a new plugin for Rails: Userstamp. You can read my
blog post at http://www.delynnberry.com/articles/2006/01/20/userstamp-plugin
and/or read all about it at the perminant page
http://www.delynnberry.com/pages/userstamp. Any comments or suggestions for
improvement are much appreciated.
--
DeLynn Berry
delynn@gmail.com
http://www.delynnberry.com
A dump of the Readme
2006 Dec 06
2
validates_uniqueness_of where scope euqals created_by "magic" field
I have the following ActiveRecord objects:
class Recipe < ActiveRecord::Base
has_many :ratings, :dependent => true
. . .
end
class Rating < ActiveRecord::Base
validates_uniqueness_of :created_by, :scope => :recipe_id
belongs_to :recipe, :counter_cache => true
. . .
end
The created_by field on Rating is implemented as a "magic" field
similar to this:
2006 Aug 12
0
insert into database failing
hi all,
i am trying a little project based on the agile book''s shopping cart
example and have hit a problem. the inserts are failing when saving a
quote which contains line_items. the models are as follows
(quote_line_item is using single table inheritance):
class Quote < ActiveRecord::Base
has_many :quote_line_items
end
class LineItem < ActiveRecord::Base
end
class
2006 Feb 26
3
Rails Naming Conventions
DB field names:
If I have a table that references 2 or more separate users from my users
table, is there a recommended naming convention for this situation? In
my case, I have 3 users associated with a record in my projects table:
requester_user_id
created_by
updated_by
I could name one of them "user_id", and then projects.user would work I
guess, but wouldn''t work
2006 Dec 11
1
Index help on Polymorphic Associations
Hello,
I''m a newbie to aaf and rails and I hope anyone can help me with this.
I have the following Models:
class Project < ActiveRecord::Base
acts_as_authorizable
acts_as_audited :except => [:created_by, :updated_by ],
:user_class_name => ''AuthenticatedSystem'', :user_method =>
''current_user''
acts_as_ferret :fields => {:name =>
2006 Jul 18
1
usermonitor / user stamping active record
Quick question about userstamping records in a similar way to
timestamping. There is an example of how this might work at:
http://wiki.rubyonrails.org/rails/pages/Howto+Add+created_by+and+updated_by/versions/7
This seems to work fine on my development system. However, I am not
sure how the User.current_user method, which is required, can guarantee
to return the correct user since this is a
2006 Sep 09
13
best way to add "created_by" entries to all tables???
Hi,
I want to automate somewhat the addition of created_by/updated_by fields
on my models (i.e. to include username). What''s the best/recommended
way to do this? Would it be to:
a) Find out how to extend the ActiveRecord::Base itself (I haven''t
extended a class before yet)
b) Use a plugin type approach where you have to add a tag manually to
each model file which then
2006 Apr 10
4
Many To Many''s Join table attributes + migrations
Hi all,
just joined and have only just kicked off with Rails (coming, but not
departing, from WebObjects development). And so far there seems to be
a lot of promise except for one thing I can''t figure out as yet --
the above problem.
Say I have the following conceptual relationships:
ITEMS <<--->> CARTS
i.e., each item can belong to one or more categories. So really
2006 Apr 12
0
class attributes and thread safety
Are class attributes thread safe? For instance, the userstamp plugin
creates a User.current_user attribute and then it aliases the
ActiveRecard create and update methods to write created_by and
updated_by attributes using the value of User.current_user. For some
reason I can imagine a case where multiple users are logged in at the
same time and saving objects, and the value of
2006 Apr 18
1
''wrong number of arguments'' for text_field?
This is probably something very simple but I can''t seem to figure out
why I keep getting the ''wrong number of arguments (1 for 2)'' error with
the following code when I try to create a new record. If anyone can see
what is going wrong here please help!
new.rhtml
-------------------------------------------------
...
<%= start_form_tag :action =>
2006 Apr 19
0
How to rubify this query
Hi guys,
i spent about 5 hours now of finding out how to rubify/railify this
query!
Maybe someone of you can help me ;)
class Menu < ActiveRecord::Base
validates_uniqueness_of :handle
validates_presence_of :name, :sequence, :accesslevel, :defaultpage,
:handle
belongs_to :cmodule
belongs_to :creator, :class_name => ''User'', :foreign_key =>
2007 Jul 30
0
Rails/MSSQL error
Hi,
I have been encountering this error when I try to save text with
japanese characters:
DBI::DatabaseError: Execute
OLE error code:80040E14 in Microsoft OLE DB Provider for SQL Server
Line 1: Incorrect syntax near ''20070730''.
HRESULT error code:0x80020009
Exception occurred.: INSERT INTO categories ([category_name],
[updated_at], [created_by],
2007 Oct 17
9
@session['user'] vs session[:user]
This might seem really simple to some but just wanted to ask: what is
the difference between @session[''user''] and session[:user] ? and how
would you use each?
And another question, I have the following code:
def get_customer
if @session[''customer'']
@c = Customer.find(@session[''customer''])
end
end
private
def
2006 Mar 26
5
How to write manage created_on and created_by via mixin?
Hi!
Definite newbie here - I''m working through this like-hate relationship with
Ruby and Rails right now... sometimes things work really well (like blobs
seem to rock) but other times, I dunno! :-)
Anyway, I''d like put in create and update user timestamps on all my primary
domain tables and allow them to be updated automatically by ActiveRecord.
Coming from Hibernate, I just
2005 Aug 09
3
Adding created_by and updated_by trouble
Hi everyone. This is a real noob question that I''m hoping someone out there
can help me with.
I have followed the tutorial How to Ad created_by and
updated_b<http://wiki.rubyonrails.com/rails/show/Howto%20Add%20created_by%20and%20updated_by>y
and it works ok for retrieving the data. I''m using the Login_Generator.
I cannot get it to work on create or update. I think
2007 Jan 03
2
Rails and bb forum integration
Hi,
I''m new to Rails. Have read the Agile book. Working on new app, its
going well.
Now, I am at a crossroads. I need to choose a bbs for my site
The significance for rails development is that I want to have single
sign on between both my Rails app and my forum.
I was just about to work on integrating the Rails SaltedLoginGenerator
into my rails app when I read this post
2013 Sep 23
1
redirect on browser success, but redirect on functional test is error
line_items.yml:
one:
product_id: 1
cart_id: 1
quantity: 1
carts.yml:
one: {}
product.rb:
has_many :line_items
cart.rb:
has_many :line_items, dependent: :destroy
line_item.rb:
belongs_to :product
belongs_to :cart
line_item_controller.rb:
def destroy
@line_item = LineItem.find(params[:id])
@cart = @line_item.cart
@line_item.destroy
respond_to do |format|
format.html