Displaying 20 results from an estimated 800 matches similar to: "Patch 10463: has_many through using uniq does not honor order"
2006 Jul 23
8
belongs_to :through ?
Suppose I have a belongs_to relationship and the thing it belongs to,
belongs in turn to something else.
For example, I would like to do:
belongs_to :city
belongs_to: :county, :through => :city
While it is not too much trouble to do obj.city.county, there are times
when I need to iterate through the attributes and include this
second-order attribute. Special code to handle this messes up
2007 Nov 23
3
CopyHandler and hidden files?
Hello,
I was wondering whether the CopyHandler plugin works with hidden files
like .htaccess? I have an .htaccess under src/ and another one under
src/code/, but they won''t be copied to output/. My config.yaml is:
File/CopyHandler:
paths: [''**/*.css'', ''**/*.js'', ''**/*.jpg'', ''**/*.png'',
2006 May 08
2
Creating a "Foo has_many bars" association where bar isn''t a model.
Hi
Let''s say we have model Foo. Each Foo instance can have several bars.
Those bars are primitive, so they shouldn''t be models. For example,
Foo might be a type of convention, and the bars might be years the
convention was held in. Naively, we would have a conventions_years
date, and put:
has_many :years
inside class Convention. But then we''d get an error, since for
2007 Nov 20
9
Testing Models without fixtures
Hi,
I would like to test a sorting method that is in the user model, it''s
a class method called search.
What I would like to do is create 2 users and load the test database
with just those 2 users, so that I can call
User.search("john") and it would return those two users.
Not sure how to clear the test database and populate it just with
these 2 users for that specific
2009 Dec 06
3
User Modification
I''m trying to do something like this using puppet 0.24.8.
define removeuser() {
@ user { $name:
ensure => absent
}
realize User["$name"]
}
$removelist = ["bob", "bill", "billy"]
@ removeuser { $removelist : }
It''s failing with "err: Could not retrieve catalog: Failed to realize
virtual resources User[bob] on node
2006 Jul 28
6
STRFTIME() why is it not defined
I am trying to take the input from a field in wich the user enters a
date, and formatting it to my time format
if params[:gotcha] != ''''
gotc = params[:date].to_a
gotc.strftime("%m/%d/%y")
end
Yet I get this error:
NoMethodError in AddController#add
undefined method `strftime? for ["00000"]
What''s wrong. I''m positive this method is
2006 Feb 14
6
Creating a String of Random Characters and Numbers
I want to create a random string of length n that is made up of
characters and integers. Is there a function in rails or ruby that
allows me to do this?
Thank you my friend :-).
John Kopanas
http://www.kopanas.com
=====================================================================
http://www.soen.info - source of the freshest software engineering
information on the net
2006 May 02
4
useful bit of code (hopefully)
Hi,
I often find myself using bits of code like this inside ActiveRecord,
perhaps it''s useful for others, or others can improve on it:
###########
# fix user input before validating it
before_validation :sanitize_input
# santize input before actual validation is called
# this uses the little methods defined below
def sanitize_input
trim %w(adres postcode woonplaats email naam
2006 May 30
4
Hide parent element
I have some code that calls a partial to display one or more blocks
within a div tag. I want to have a close button (or cancel link) that
will fade that block but leave the others. Here is the code:
LINK:
<%= link_to_remote "Add Miscellaneous Link", :url => { :action =>
:add_iyc_link } %>
add_iyc_link.rjs:
page.insert_html :bottom, ''links'', :partial
2007 Nov 29
3
Strange Array behaviour
I''m having a strange thing when using the Enumerable extensions for
Rails:
Have a look at the following code:
class Invoice < ActiveRecord::Base
has_many :invoice_lines
def total
invoice_lines.sum(&:total)
end
end
class InvoiceLine < ActiveRecord::Base
belongs_to :invoice
def total
amount * price
end
end
Now, when calling invoice.total, I get wrong
2005 Dec 21
1
Are Ducks Hibernating ?
Dears,
Remembering last value in a select box don''t work for me as :
Controller :
@years=(1970..2005).to_a
Form:
<%= select_tag "year", options_for_select( (2001..2005).to_a,
@params[:year] ) %>
I had to write
<%= select_tag "year", options_for_select( (2001..2005).to_a,
@params[:year].to_i ) %>
for it works.
Not important, but I''m
2006 Apr 10
9
Pagination with letter (A B C D ... Z)
Hi there,
Is there a neat and easy way to implement pagination with letters
rather than numbers eg :
A B C D ... Z
Rob
2013 Sep 02
2
Why the string interpolation is not working inside the Nokogiri method `#search` ?
Why the string interpolation is not working inside the Nokogiri method
`#search` ?
require ''nokogiri''
doc = Nokogiri::HTML::Document.parse <<-eotl
<div>
<p>foo</p>
<p>foo</p>
<p>bar</p>
</div>
eotl
doc.class # => Nokogiri::HTML::Document
class Person
attr_accessor :name
end
ram = Person.new
2007 Mar 29
7
object-oriented GUI design and event handling
I''m trying to setup a fairly simple GUI with Ruby to perform some SQL
queries. There are a few drop-down boxes where users can select
different options and then one button that when clicked should get the
text from each drop-down in order to perform the query. Once it gets the
result it should display it to a text control. The problem is I am not
sure how to actually reference each
2006 Mar 18
4
Accessing overridden method
I have two model classes:
class Item < ActiveRecord::Base
belongs_to :channel, :counter_cache => true
validates_presence_of :channel
end
class Channel < ActiveRecord::Base
has_many :items, :dependent => true
end
In the Channel controller I have variable channel.items, an Array of
Items. I would like to use the Array find method. However,
channel.items.find() is a Rails
2010 May 28
2
Suggestion for improving value_to_boolean column conversion
Hi fantastic rails core developers.
Speaking of version 2.3.5:
I find it rather error_prone that values such that "some text" is
silently converted to false when stored in a boolean DB field.
Among other things it means that assign "some text" to boolean fields
on a model will not generate any validation messages (it will silently
be converted to false).
I think it is like
2008 Jan 30
6
Schedule parser
Hi,
I was trying to schedule a worker to run during the midnight hour
like this:
:schedules:
:collector:
:process_something:
:trigger_args: 30 * 0 * * 2,3,4,5,6
When I try to start backgroundrb, the "collector" worker failed to
start up and I find this in backgroundrb_server.log:
/home/mengkuan/apps/testrailsapp/current/vendor/plugins/backgroundrb/
2005 Apr 18
3
RBAC?
hi all,
I posted this earlier:
are there any RBAC (role based access control) efforts in rails? code
to support? external, open source project(s)? etc?
any help much appreciated, if none exists we''ll build it and anyone who
wants to help is welcome :)
_alex
--
alex black, founder
the turing studio, inc.
510.666.0074
root-16h2cdTTKgpzNNFeSAH1EA@public.gmane.org
2011 Sep 19
7
how to get instance variables in another action in rails 3
In my controller show method i have two instance variables which have
large amount of data and take much time to fetch from remote system.
shown below
def show
@graph = Koala::Facebook::GraphAPI.new(session[:fbuser]
["credentials"]["token"])
@friends = @graph.get_connections("me", "friends")
@friends =@friends.to_a
end
in the same controller I
2005 Oct 11
4
Searching an attribute in a hmabtm relationship
(Nuby to Ruby and Rails...)
I''ve implemented security using the login generator in a simple app so
that I have a user table, a roles table, and a join between them
(roles_users). All works as expected. I now need to check if a user
has a specific role, but my approach is off somehow.
Here''s what I''ve tried thusfar:
user_roles = @session[:user].roles