Displaying 20 results from an estimated 800 matches similar to: "Interpolation in association conditions broken; broken backwards-compatibility?"
2005 Oct 26
0
Expression Interpolation and ActiveRecord relationships
All,
I''m having some difficulties with the #{} replacements in ActiveRecord
that I haven''t seen mentioned on the list.
I have a number of has_many relationships that use finder_sql queries
dependent on dynamic data. I''ve seen that you need to single-quote the
queries to make your terms work, and that''s been good for simple cases.
What I''ve found
2011 Feb 17
1
Select distinict on not chainable with order method
Hi.
I would like to do code refactoring:
@beers = []
Beer.all.each do |beer|
unless @beers.find{|c| c.brand_id == beer.brand_id}
@beers << beer
end
break if @beers.size > 29
end
So I achieved this by writing scope (on PostgreSQL):
scope :with_unique_brand, select("DISTINCT ON (beers.brand_id)
beers.*")
Using this scope alone is working
2008 Jul 22
2
ActiveRecord Associations issue
Hello all and thank you for reading this message.
I am new to RoR, and ruby too, but i am quite excited about it.
I am developing a RoR project and with active record associations in
the following
manner
# Tables (all tables have only one record)
CREATE TABLE `webcars_development`.`cars` (
`id` int(11) NOT NULL auto_increment,
`model_id` int(11) NOT NULL default ''0'',
2012 Mar 28
1
collection_select
_form.html.haml
= f.label :Select_Brand, "Select_Brand<em>*</em>".html_safe
= collection_select(:brand_name, :brand_id, Brand.all, :id, :name,
:prompt => "Select a Brand" )
show.html.haml file
%table
%tr
%td
Brand_Name :
%td
= @message.brand_id
After writing this code I am not able to see the brand name. Its not
giving any error but
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
2001 Mar 22
5
Major network slowdown today... Samba the cause?
Today, our network has been excruciatingly slow. I checked the log.nmb
file, and I noticed that today, the Samba PDC has been losing its "local
master browser" status every 2 minutes or so, for about 15 seconds, to a
Win9x client.
Before today, this also happened, but only a few times each day.
Network configuration:
1. All clients are Win9x.
2. Server is SuSE 6.1, with Samba 2.0.5.
2010 Jun 17
1
Problem with options_for_select
Hi,
I have a problem with the form select. In the value field I have the
generated html...
<%= f.select :brand_id,
options_for_select([[''Brands'', 0]] +
@search_brands.map { |b| [b.name, b.id]}),
{:id => ''cbxBrand'', :tabindex => (@tabindex += 1)} %>
This is the html:
<select name="search[brand_id]"
2007 May 30
2
newb trying to figure out ActiveRecord relationships
3 tables. item, brand, commercial
item
--------
id
name
brand_id
name
brand
---------
id
name
commercial
----------
id
item_id
The idea is that a commercial will have one item.
each item will have brand.
and a brand may have zero to many items.
I can''t figure out how to make the relationships for my models.
Eventually, i''d like to be able to show a brand name from a
2006 Jul 19
5
weird result for a custom attr reader!
Hi all,
I am having a weird problem reading a value from my model. basicaly, I
have these two models:
class Category < ActiveRecord::Base
acts_as_tree :order => "name"
belongs_to :item_type
has_many :specific_category_names
end
and
class SpecificCategoryName < ActiveRecord::Base
set_table_name "Specific_category_names"
has_many :products
belongs_to
2006 Aug 09
1
Migrating a Field to External Model
I have a model Product with an attribute ''brand''. Currently it is a
simple attribute, however, I am migrating it to a separate model
Brand so that I can have other attributes with each brand. I created
the the model and created and ran the migration to create the new
table. So far so good. Then I created a separate migration to
transfer the data. The up method
2006 Jul 15
1
Relationship problem, newbie problem, need help!!
Hey all
I seem to be having some problems with my relationship between a few
tables...
If i then run the following query in mysql, i get the data i want. How
do i do this in rails relationships and models?
select * from shop_addresses
left join shops on shops.id = shop_addresses.shop_id
left join styles on styles.id = shops.style_id
where shop_uri = ''127.0.0.1''
Cheers!!
2006 Feb 15
3
Like Query Across Multiple Tables
Firstly, I''m still learning Ruby and rails, so there could be a very
simple solution to this.
I want to search across multiple tables with a "like" query eg: (SQL is
probably the easiest way to describe it):
select
products.*
from products
inner join brands on products.brand_id = brands.id
where
products.name like ''%canon%''
or brands.name like
2008 Jan 07
0
HTML handling in SuperRedCloth
I''m having all kinds of fun trying to get HTML to work "properly" in
SRC (mild sarcasm). I''m still working on the problem, but wanted to
run it by the group.
Currently, Textile2 lets you put in HTML as long as it''s in the same
block (i.e. no double-returns).
<ul>
<li>You can put HTML code right in Textile.</li>
<li>It will
2009 Jun 07
1
Close to a 4.2 release; experimenting with Ragel alternatives
Hi Jason !
Hmmm, this is good and bad news:
Good: ruby hooks means I could use a single pass to parse textile
customizations in zena instead of running two parsers: nice.
Bad: I have just switched to ragel for QueryBuilder to parse pseudo
sql and I fear your shortcomings (if that''s an english phrase).
Could you describe more precisely what you are missing with ragel ?
I''m
1999 Sep 22
4
Group Policies
I was told that this mailing list might be a good place to get some
answers that another one I'm on couldn't answer.
I am using Samba to serve a small Christian school in PA, and we went
for it mostly because of the cost - how much better than free can you
get! I've been very pleased with it, as it's my first server setup.
Learned a lot and have gotten a lot of help. However,
2007 Aug 23
20
Eliminating bad tests from SuperRedCloth
Hi, all. I haven''t felt at liberty to go axing test cases, but some
of the 33 that are failing now are ones I don''t think we want to pass?
cruft coming from Markdown or made up to fill a gap some years ago.
I''d like to float the proposition that we make Super (and thus
RedCloth 4) behave as identically as possible to Textile2 as working
on
2006 Sep 28
15
Inserting rows into linking table
Hi,
I have two objects:
Contacts
Lists
I want to be able to add multiple contacts to multiple lists.
I''ve created a linking table and a form that allows me to select the
contacts using checkboxes, but I''m having some problems with the
controller and model.
I receive the following error message when I submit the form:
Mysql::Error: Cannot add or update a child row: a
2009 Jun 02
9
XML::LibXML::Reader
is there anybody who knows how we can get child values using libxml
(Reader class)
def xml_import_to_brands
require''xml''
reader = XML::Reader.file(''c:/brands.xml'')
.
.
.
2009 Jul 23
11
Problem with named_scope
Here are my scopes:
default_scope :order => ''posted_on DESC'', :conditions => { :status =>
''visible'' }
named_scope :positive, :conditions => { :rating => ''positive'', :status
=> ''visible'' }
named_scope :neutral, :conditions => { :rating => ''neutral'', :status
=>
2008 Mar 15
8
Now what?
> $ rake test
> /usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/
> rake-0.7.3/lib/rake/rake_test_loader.rb" "test/test_formatters.rb"
> "test/test_parser.rb"
> Loaded suite /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/
> rake_test_loader
> Started
>