Displaying 20 results from an estimated 2000 matches similar to: "How to access parent property"
2009 Jul 02
8
rails hyperthreading on Quad core
Hi, my video sharing website (politube.org) that I developed with rails,
runs on lighttpd/fcgi (I know it is obsolete by now) and is severely
under load and regularly blocks because the lighttpd process chews up
50% of RAM (1GB).
So now I want to move the system to a new server with 8GB, 64bit ,
Quad core processor (intel i7 920) but I am not sure if hyperthreading
will really do anything better.
2009 Jun 22
12
Rails Hosting: Slicehost vs. Rimuhosting
I know similar topics have been covered before, but I''d like to get a
more up-to-date Ruby developer''s opinions. (Please note that I''ve
read similar threads in this group and read a lot of hosting
comparison sites, even contacted both companies and am still having a
hard time making decisions. )
After reading about limitations with shared hosting plans, I decided
that
2009 Aug 13
10
default value if textfield is empty
Hey all,
im not sure where to set a default value if a textfield is empty?
For now i do it in the controller, and check if the submitted parameter
is blank.
But this seems not to be the best solution...
Thanks for your help!
--
Posted via http://www.ruby-forum.com/.
2010 Feb 01
3
validating both sides of a has_one relationship breaks pickle/machinist tests
A lot has been posted about validation issues with associations,
however, I don''t see this issue addressed specifically.
ex:
class Foo
has_one :schedule, :dependent => :destroy
validates_presence_of :schedule
class Schedule
belongs_to :foo
validates_presence_of :foo_id
this creates a circular dependency that breaks test frameworks like
pickle and machinist.
At first I was
2010 Dec 14
5
Build associated model confusion
I''m new to Rails3, and I''m just trying to get one last thing to work
before I call it a night. The situation is the following (please if
the code is horrible, just let me know, still learning):
I want to log a dive. I might have a new location on that dive at
which point I have to create a new Location, and then create the dive.
A dive has_one location. A location has_many
2006 Mar 11
2
Latest kernel seems to have found my second NIC
I just yum-installed the 2.6.9-34 kernel RPMs and rebooted, and lo and
behold, my other onboard NIC is now detected, after a fashion.
/etc/sysconfig/hwconf now has entries for:
device: eth0
driver: forcedeth
desc: "nVidia Corporation CK804 Ethernet Controller"
device: eth2
driver: sky2
desc: "Marvell Technology Group Ltd. 88E8053 Gigabit Ethernet Controller"
The device/desc
2012 Nov 10
6
Suggestion: `before_save on: :create` should either work or raise an exception
There''s a small inconsistency in ActiveRecord''s callback syntax that has
tripped me up before. It wouldn''t be a big deal, but it can lead to a
silent failure. I''d like to suggest that it either be made consistent or be
made to fail loudly.
The issue is that to do something before validating, but only when
creating, you use `before_validation on: :create`,
2006 Nov 17
4
set empty values as null in the database
Le''s say that I have a table called people and the column middle_name is
nullable. If the user enters say blank or empty space then in the database
it is recorded as empty space. I would like in all my models all empty
spaces to be recorded as null.
I guess I can write a plugin which will do so for all the models but I''m
sure something like that should already be existing.I
2009 Feb 07
5
before_save :strip_whitespace => saves with spaces
i used this private function for removing leading and trailing white
spaces from the values.that below function would be called before_save.
when i print the value after it strips.it prints string without any
spaces.but in the table fields it saves with spaces .
waht would be the problem.pls help me
class CompanyInfo < ActiveRecord::Base
before_save :strip_whitespace
def strip_whitespace
2008 Jun 29
3
Working around/with Restful Authentication
I''m using Restful Authentication, and the code to create a user is
pretty straight forward - there is a before_save action and a
before_create action:
before_save :encrypt_password
before_create :make_activation_code
But for some reason when I try to create a user programmatically in
the controller like this:
User.new(:email =>
2011 Oct 14
2
before_save :encrypt_password
I am having a problem finding the best way to make a "before_save
:encrypt_password" conditional.
I have to at times update user model attributes but each time I do this
the password is reencrypted because of the above. I need to
differentiate between when the user is first logging in and the password
does need to be encrypted, and when they are already logged in and the
2010 Jun 17
7
Why do rails calls a method when I'm calling a property?
Well, I''m starting on RoR, so I got a Book called simply
rails...Following the steps in it sometimes when I try to call a
property, the browser shows me the next exception:
undefined method `name'' for nil:NilClass
I don''t know why...here''s my controller:
#Controller starts here
class StoriesController < ApplicationController
before_filter :login_required,
2008 Jul 10
6
Uppercase all row columns
Hi.
I have to convert the contents of all columns to uppercase before
creating a row. Is there an easy way to accomplish this so I don''t
have to go one column at a time and upcase! it?
Thanks.
Pepe
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group,
2006 Mar 02
2
How to get mime extension with file_column
Is there a way to get the MIME extension of a file_column field?
Here''s what I want to do (look for comment in before_save method):
class ProductFile < ActiveRecord::Base
belongs_to :product
file_column :file_name
def before_save
self.file_type = # something that returns the MIME type (e.g. image/jpeg)
end
end
TIA
2009 Mar 17
4
Preventing a submitted hash from ActiveRecord DB store
Hi all,
I have a multi model form (Project with many tasks) and I want to
prevent a task from being saved to the DB if it is empty ie. if there
is no i/p for that task from the user. I tried the following
class Task < ActiveRecord::Base
before_save :check_if_empty
...
def check_if_empty
self.destroy if description.blank?
end
but i get this
TypeError in ProjectsController#create
2006 Feb 11
5
after_(read|find) callback?
I am pondering the possibility of encrypting/decrypting some fields
in a SQLite backend on-the-fly.
The point of the message is not security, I know that''s broken, but
whether there''s a technique that provides on-the-fly save/read
filters. Of course the solution would need to work transparently in
joins, so
user.posts.last.title
would do the right thing if title
2006 Feb 10
4
before_save gotcha
Is it will known and accepted that before_save triggers should return
true? I didn''t notice this before but now I see it in the
documentation.
Here is what I''m doing in my model:
def before_save
if self.has_album?
self.visible = self.album.visible?
end
end
That results in the expected result when album.visible? is true - but
not when it is false. To make it
2007 Jun 27
3
acts_as_tree and before_save
We all know that acts_as_tree gives us ability to set up data in a
tree-like structure and use methods like ''parent'', ''children'' and so on.
Something I''m completely stuck on. Observe.
class Page < ActiveRecord::Base
acts_as_tree
def before_save
raise self.parent.to_yaml
end
end
Well, you''d think that it should show
2006 Mar 24
2
Access to session data
Greetings,
This, I hope, is a simply answered question.
Based on Agile Web Development with Rails (depot application), I''m
developing a single table application for contact info. There is only
an admin side to this, so there''s always authentication.
Part of the info record (member) is changed_by and changed_at which I
automatically want updated. Changed_at looks after
2006 Jan 25
7
join fields for list views
I am sitting with the Agile book on my desk and scratching my head at
the discussion on aggregation - perhaps that isn''t what I need.
I have a db called clients.
fields include - first_name middle_initial last_name
I want to combine them all into one name element in a list view. I can
add/edit the fields separately but in the list view, I only want the one
combo field.
Is there a