Displaying 20 results from an estimated 10000 matches similar to: "Updating an attribute in db"
2006 May 18
6
Form actions with additional parameters
Hiall,
I want to give the action of a form an additional parameters but can''t
figure out how to do it. My code looks like this
<%= start_form_tag :action => ''create'', next_step => true %>
<%= render :partial => ''user_form'' %>
<%= render :partial => ''community_form'' %>
<%= submit_tag
2008 Apr 07
7
Saving attribute
Something is getting lost here.
def create
@home = Team.find_by_user_id(current_user.id)
for player in @home.players
player.update_attribute(:game_id, @game.id)
end
end
def show
@players = Player.find_all_by_game_id(params[:id])
end
view
<%= @players.size %> # mistakenly equals zero
Played with the console and everything should be working fine...
2007 Feb 24
2
RESTful PUT and button_to
I''m working on a RESTful app, and I''ve hit a snag. Here''s a
simplified example of the problem. (Excuse me if this example code
isn''t strictly correct; I''m typing from memory.)
Suppose I have a table which models a simple counter. It has a single
column, "count":
class CreateCounters < ActiveRecord::Migration
def self.up
2006 Jun 08
5
update only the join table in a HABTM - how?
I have a photographers app that requires giving access to galleries for
users. in one part, I want to be able to define gallery access for a
user seperate from updating any of the user info. I have this function:
def edit_access
@user = User.find(params[:id])
@user.galleries = Gallery.find(params[:gallery_ids]) if
params[:gallery_ids]
if @user.update_attributes(params[:user])
2011 Aug 14
5
Puzzled with form on multiple table rows
I''ve got a table of events, and each event has a boolean attribute
is_ten_event.
On each row of the table is a chekbox to edit the value of is_ten_event,
so that multiple rows can be edited with one submit.
In order to allow boxes to be un-checked as well, the logic in the
controller works like this
get array of events from checkboxes that are ticked.
make all events.is_ten_event =
2009 Dec 18
2
Undefined Method error - help request
Good morning All -
I am working on a time tracking application as a learning excercise
and have run into an error neither I nor Google can remedy.
When loading my view, I get an error: ''undefined method
''true_class_path'' for #<ActionView::Base:.........
Context:
I have controllers for Project, Worktrack and ''Workbench'', among
others. Workbench is
2006 Jul 17
19
updating model
hello,
i am writing a simple user login system.
when registering a user account, i have two field:
password
password_confirmation
which are validated using
validates_presence_of
validates_confirmation_of
and these are then used to generate a password hash which is stored in
my database
when i want to update the record (without changing the password and
entering new values for password and
2006 Jan 02
5
How to use MySQL sum() to get total of column?
Easy one: Let''s say I have a table called ''employees'' with a column
called salaries, how can I add Employee.salaries_total to the model?
Thanks!
--
Posted via http://www.ruby-forum.com/.
2006 Jan 03
5
update command not updating DB
I really need your help guys... I spent 6 hours on this simple update
command today that should work. It works fine in my other controller,
but doesn''t work in this one for some reason.
Here is my controller code for the list view, and then the update
command:
======
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if
2011 Aug 15
2
Delayed_Job: code working fine without .delay / with .delay it fails. Why?
Hi all,
I wrote a simple code to set up the "pit_id" from a village table from
1 to 2, from 2 to 3 and so on.
It works fine without .delay . But i need it so whats wrong with that
code?
#village_controller
def post_info
@village = Village.find(params[:id])
@village.delay.upgrade
flash[:notice] = "Upgrading"
redirect_to village_url(@village)
end
2006 Mar 11
2
ActiveRecord increment confusion
Part of my application counts the number of times a link was clicked.
The Link.click function should increment the @link.clicks attribute.
I assumed
def click
@link = Link.find(params[:id])
if @link.increment(''clicks'')
redirect_to @link.url
else
flash[:error] = ''Could not update clicks''
redirect_to :action =>
2006 Jan 30
5
Action Mailer woes
Hi gang,
Im having my first stab at ActionMailer and not having any luck. Perhaps
someone could help me out.
I generated a a mailer called ItemMailer - its purpose is to take some
information that I''ve already gathered in a ToDo list form and to mail
it out to the person who is nominated for the task
In environment.rb I have;
ActionMailer::Base.server_settings = {
:address =>
2006 Aug 14
2
Change password
Is there an addition to the Rails Recipe or the method in AWDWR to allow
a user to change his/ her password? I have put something together that
does all the work again - mostly because I''m not sure how to leverage on
methods like ''password='' that are defined in the model. Has anyone got
a ready sample that I could learn from?
Right now, I''m basically
2006 Jul 12
1
Question re: Computing a field in a DB record
I''m just learning Rails and have encountered a problem trying to set
a field in a DB record based on the value of another form input
field. Using the scaffold code, the create works as expected and the
update (edit) also works. However, one of the DB fields (amount) is
supposed to be computer from another (units): if the category field
is "Mileage", amount= units *
2009 Nov 11
6
HeLp oN my database
Using my application i can able to save a new record into my db
but i cannot update a existing record into my db.
using update query i can able to update my records.
but using update_attributes it doesnot update my records.
even i cant find any errors in logs or something.
throughout my application i can able to save a new record but unable to
update my existing records.
actually i have changed
2006 May 25
1
AppMailer and McCray''s theme generator
Hi,
I am using Matt McCray''s theme generator.
http://rubyforge.org/projects/theme-generator/
Everything works fine, but rendering an action in a controller using
the AppMailer raises this:
undefined method `current_theme'' for #<AppMailer:0x39df950>
Is there someone who could help me ?
Thanks !
Mickael.
Traces:
2006 Aug 08
1
form parameter
How can I change some parameters in a function of the controller. I have
a User_Controller, who''s responsible for update the information fields
in the database.
The parameters are "id", "firstname" and "lastname". Now, I want to
manipulate parameter "lastname", because I would like to add at the end
a point.
>> Thomas Miller
2006 Jun 10
3
Inserting data to another DB table
I have a form under one controller/model called "billing" using the
"bills" table. When this form completes I want it to change the
"has_billing" field for the user under the "users" table from "0" to
"1". I''ve almost got it. I put:
user = User.new
user.update_attribute("has_billing", "1")
under the
2006 Jul 04
1
LoginGenerator Problem
I am trying to make a barebones login system based on this example
(which in turn is just standard RoR login) but when I enter a user name
and password, it says the login is unsuccessful every time. I am not
sure where I am going wrong. Here is all relevent information
CREATE TABLE `users` (
`id` int(6) unsigned NOT NULL auto_increment,
`login` varchar(20) NOT NULL default
2006 Jun 14
3
Attributes for a model which are excluded from DB?
If I want to do this but not save to the database, how can I go about
it?
things.each do |thing|
changed = someotherqueryresult
thing.update_attribute :testattrib, changed
end
Essentially I want to create a collection called things with some extra
attributes that are not saved into the database, as they are just used
for sorting in a view and should not be saved (in fact saving them
wastes