Displaying 20 results from an estimated 1000 matches similar to: "this feels ugly"
2006 Apr 20
5
strange mysql problem
i have this model:
class LineItem < ActiveRecord::Base
belongs_to :quote
end
in the console:
>>l = LineItem.create
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '' , , , )'' at line 1:
INSERT INTO line_items (`qty`, `quote_id`,
2006 Apr 18
1
what happened to my increment_counter method?
this used to work for me. i started re-writing my little app and now
it doesn''t work.
here''s my models:
class Company < ActiveRecord::Base
has_many :people
end
class Person < ActiveRecord::Base
belongs_to :Company, :counter_cache => true
end
then i go into my console and say:
c = Company.find(:first)
c.increment_counter
and its all like "waaaaaaH"
2007 Jun 18
2
extending Array class with a method
Hi,
Let''s say I have an ActiveRecord::Base class and I want to be able to
call a method on an Array of these items. For instance, perhaps
there''s a class called Country and another called business, and I''d
like to be able to do something like
great_white_north = Country.find_by_name(''Canada'')
canuck_enterprises = great_white_north.businesses
2010 Sep 12
11
Rails 3: finding a record by name in multilingual app
Hello,
I upgraded my application from Rails 2 to Rails 3 and ran into a
problem. In rails 2 I could use the english name of the record to find
it like:
Page.find_by_name("Welcome")
even though the user chose German as the language (which of course
showed the German welcome page.
Eversince I switched to Rails 3 (default_locale still :en) I can''t find
anything by giving the
2008 Jul 08
3
undefined method `name' ...........
Hi Community....
I''m new in this game, so this might be a easy question, but I have
done my google, without result, so I will try this....
I''m learning ROR, and I''m using Patrick Lens ''Ruby on Rails'' book.
(This is written for ror 1.x - and I''m using NetBeans 6.1 - ror 2.x -
this might be the problem...)
But...
I have made this
2013 Mar 28
1
undefined method 'sanitize_limit' for #<ActiveRecord::Relation:0x2aaaad35d720>
I am trying to upgrate rails from 3.0 to 3.1, while updating rails version
I am getting following error
rake aborted!
undefined method `sanitize_limit'' for
#<ActiveRecord::Relation:0x2aaaad35d720>
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:460:in
`method_missing''
2006 Aug 14
4
Controller method problem
Hi,
I have a def in my controller see below where i want to find the page
object based on a parameter value and then use the page_id to then find
all the contents that belong to that page in the same method.
Controller
def aboutus
@page = Page.find_by_name(params[''About Us''])
@contents = Content.find(:all,
:conditions => "page_id = #{@page.id}")
end
2007 Jun 23
3
has_and_belongs_to_many and dynamic find
Hi
Just curious if anyone can explain why using a dynamic find fails to
work with << operator
I have standard habtm relationship
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
Now when I assign a Role via << after saving the new User I get wierd
behaviour
but only when using the dynamic version of find
i.e
@user = User.new(p)
if @user.save
#
2006 Mar 02
3
Modifying "Find" to always add a condition?
I''d like to always add a condition to any version of "find" (e.g.
Thing.find(), Thing.find_by_name(), Thing.find_by_whatever) so that in
addition to whatever conditions are set, an additional condition is set
:conditions=>"user_id=#{current_user.id}"
I''d like to make sure that a user only sees/edits/creates entries in the
database that have the user_id
2007 May 22
3
can I use acts_as_list with a has_many :through association
I''d like to be able to use a has_many :through association and treat
the associations as a list but I''m getting this error when I try an
use an acts_as_list method:
NoMethodError: undefined method `move_to_bottom''
I''m using edge rails r6786.
Here are my domain rules:
Activities are things students can do.
Units consists of a sequenced list of
2006 Jul 31
2
Updating a belongs_to foreign key leaves the old association object available
Perhaps this is intentional, but it seems unlikely:
class Person < ActiveRecord::Base
belongs_to :school
end
p = Person.find(:first)
p.school # nil
p.school_id = School.find_by_name(''High School'').id
p.school.name # High School
p.school_id = School.find_by_name(''Primary School'').id
p.school.name # High School <= Shouldn''t this be Primary
2006 Apr 22
3
how do I manually throw a 404?
I''m sure this has been asked before but a quick search on the web didn''t
give me any hints..
I''d like to do this:
@person = Person.find_by_name
throw_page_not_found unless @person
Anybody know how to do this, do I have to manually tinker with the
response object?
--
Posted via http://www.ruby-forum.com/.
2006 May 29
4
Prompting user to enter value to feed Find
Hi,
While viewing part of a long list of records, the user may want to do a
Find of a specific record (for example, find_by_name). The found record
is then displayed using the list view. I''ve searched the wiki and
couldn''t find a sample or information that will help directly in
implementing this function. Any pointers?
Thanks!
gk
--
Posted via http://www.ruby-forum.com/.
2009 May 12
4
has_many :through and scopes: how to mutate the set of associated objects?
I have a model layer containing Movie, Person, Role, and RoleType,
making it possible to express facts such as "Clint Easterbunny is
director of the movie Gran Milano".
The relevant model and associations look like this
class Movie < ActiveRecord::Base
has_many :roles, :include => :role_type, :dependent => :destroy
has_many :participants, :through => :roles, :source
2006 Jul 03
2
Still struggling with data flow ...
Hello,
The following view:
<%= start_form_tag %>
Enter term to find
<p>
<%= text_field_tag :name, params[:name] %>
</p>
<%= link_to "Find", { :action => ''find_term''} %>
<%= end_form_tag %>
does not appear to pass back the value of :name to the action:
def find_term
term =
2006 Jun 11
2
Finding a record and showing it -- how?
I''d like to prompt a user for the value of a Name field, then display
the record. Rails tells me that it cannot do a find without an ID. I
guess it must be that I''m not passing back properly the data from the
view to the controller.
Thanks for the help
joshi
The find_user.rhtml view:
<div class="find-name-form">
<fieldset>
<legend>Enter User
2006 Apr 18
4
how would you take the duplication out of this?
i have these two really similar methods in my addressbook controller.
def edit_company
@company = Company.find(params[:id])
if request.post? and @company.update_attributes(params[:company])
flash[:notice] = ''Company was successfully edited.''
redirect_to :action => ''show'', :id => @company
end
end
def edit_person
2006 Feb 13
1
autocomplete input field name
Hi All,
I''m new to ruby on rails and I struggle with a problem in my first
application. I searched the forum (and ofcourse google) but I think it
is just an easy thing that nobody boughters to write down :)
I am building a kind of library application for (fysical) books and
e-books and later I want to add other functions like knowledge
management.
The problem: in the book show page
2006 Feb 26
1
HABTM SQL generated
I have a HABTM relationship between 2 tables : companies and services.
I want to find all the companies who provide a particular service so I''m
using @companies = Service.find_by_name(''servicename'').companies.
But in the development log, rails appears to be making 2 sql calls - one
to find the id of the service and a 2nd to find the companies by that
id.
How can i
2010 Jun 06
3
194 Kernel Panic; 164 is Fine; How Do I Debug?
I have a machine that has worked fine for years on CentOS5.
kernel-PAE-2.6.18-164.15.1.el5 is the last "works fine" kernel, but
kernel-PAE-2.6.18-194.3.1.el5 crashes at boot every time.
I tried banging on the side of the monitor to no avail.
All kidding aside, here are pictures of my monitor when booting 194 in
case that is helpful.