Displaying 20 results from an estimated 60000 matches similar to: "More concise edit methods"
2006 Mar 10
2
adding to has_many on create and edit
Hello,
I am fairly new to RoR and I have a question I hope can be solved
elegantly (so many things are, so why not this one too?). I have a
working solution, but I want to be sure I am doing things the "rails
way" (having come from PHP). You could say I am looking for a little
validation (no flames please).
I have a table of units like so:
CREATE TABLE `units` (
`id`
2006 Apr 27
2
NoMethodError - why?
Getting this error when hitting update.
NoMethodError in Article#update
You have a nil object when you didn''t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occured while evaluating nil.update_attributes
Source code.
def create
@article = Article.new(params[:article])
@article.user = @session[''user'']
if @article.save
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 *
2006 Dec 11
0
auth_generator 2.0.1 undefined method `login_required' for ... ArticlesController
I am a relative RubNub and attempting to implement auth_generator v.2.0.1.
I am getting an "undefined method `login_required'' for
#<ArticlesController:0xb732c0b4>" error when I attempt...
http://localhost:3000/articles/new
Help would be appreciated.
My app/controllers/application.rb reads...
------------------------------------------------------------------------
2005 Dec 16
0
More HABTM Save Problems/Issues.. bugs?
I seem to be having a problem working with an object which has a
HABTM relationship with another object I know there''s been a lot of
talk recently about problems using dual HABTM in a single object but
I believe this may be a separate issue. It appears like I''m unable to
persist this relationship (i.e. the object saves but none of the
entries in the join table are
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 Jan 05
2
help - edit without using scaffold
Hello,
What am I doing wrong? The code below does not show the current record for editing.
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:notice] = ''User was successfully updated.''
redirect_to :action => ''show'', :id => @user
else
render :action
2008 Jul 08
1
Problems with form_remote_tag
Hi,
I am trying to use form_remote_tag to update a record and then update
the section of the page where id=''opertion_panel''. There is a javascript
validation that validates the input before the record is being updated.
This validation works and the record was successfully updated. The
problem is after the record is being updated, it didn''t update
operation_panel.
2006 Jan 15
0
update_attributes not working
I dont know if its me or the dodgy win-32 intall of ruby/mysql, but I
can''t seem to get update_attributes to work.
In my user controller, I have:
def update
@user = User.find(@params[''user'']["id"])
if @user.update_attributes(@params["user"])
flash["success"] = "Updated Successfully"
redirect_to :action =>
2010 Apr 14
1
Rails validations app specific problems
Hi all,
I have a unique workflow where it''s making the use of validations
difficult.
My app is for internal use in my company and I have a funky
implementation (inspired by the e-commerce Railscasts episodes) of a
cart. I have products which when I "add to cart" creates an order with a
state of "incomplete". The product is a line item of my order. Hope that
makes
2006 Mar 16
2
please help: "undefined method ''updated?''"
Hi,
after updating to rails1.0 (using the debian package) and following the
instructions at http://manuals.rubyonrails.com/read/chapter/120
I always get in my rails application the following error:
"undefined method `updated?'' for #<Device:0xb6c95564>"
when I want to save (create or update) an interface or device-object
(as explanation: devices are servers, which have
2006 Feb 25
1
checkbox helper question
I used scaffolding, then modified. As an after thought I added a
"boolean" checkbox to my database, form with this tag
<p>
<%= check_box ''is_hot_item'', @photo.is_hot_item %>
<label for="is_hot_item">hot item?</label><br>
</p>
I check it and save. But I don''t get 1 saved in my database field.
:(
I have just the
2007 Oct 01
3
stringify_keys!
I have seen this numerious times and still have no idea what it means:
undefined method `stringify_keys!'' for "blah22":String
I am tring to change a password. My code looks like:
def change_password
@user = User.find_by_emailaddr( params[:email] )
if @user.nil? # user profile not created
flash[:notice] = "<b style = \"color:red\">No such
2006 Jul 27
1
Weird issue with editing data.
Hi all.
Ive got a small CRUD app that is giving me some weird isuses.
If I add/create an entry that works fine, the data goes into the db. I
can later show the data, but when I edit it, no data is displayed in the
form for me to edit.
Here is the bits from the controller.
def new
@kb=Knowledgebase.new
end
def create
@kb= Knowledgebase.new(params[:kb])
if @kb.save
2007 Jul 31
0
Edit not working with named routes
HELP! I''m a relatively new rails user and I''m stuck. I''m trying to
build a relatively simple blog and I decided that I liked the way
named routes look in the code. So I added
map.resources :posts
to my routes.db file. I then went through and updated my controller to
take advantage of the named routes that were generated. I also updated
all of my views and everything
2007 Jan 10
0
many_to_many relationship problem
Hello everyone, i wonder if someone can help i''m a newcomer and this
problem is driving me crazy.
I have this two models with a habtm relationship Entidad(entity) and
Persona(person), on the people view i want to see the entity/es he
belongs to and viceversa, so far so good.
The thing im getting stuck is with the form that handles the editing to
add more people to an entity, heres what i
2006 Jun 20
0
No opening form tag in rendered HTML
I cannot get my form to submit for my simple blog site (based on the "How to Build a Blog Engine in 15 Minutes" presentation)
Any ideas?
Thanks,
Tom
----------------------------------------------------------------------------
Here is my code:
#Post controller
class PostsController < ApplicationController
def index
list
render :action => ''list''
end
2008 Sep 10
5
xmlhttprequest for updating
Hello,
I am updating an object with an AJAX form:
view:
<% remote_form_for(@sample, :update => "content2") do %>
<p>
parameter: <br />
<%= select("sample","parameter",Parameter.find(:all).collect {|p|
[p.description.gsub(''_'', '' ''),p.id]},{},{:size => 4, :multiple =>
true}) %>
2006 May 11
1
RoR completely ignoring a column when saving changes
I have an action that needs to update two models/two tables in one shot,
and it works great, but ignores one column. Here is the action code:
(verify_id is irrelevant in this case)
[CODE]
def edit
@page_title = "Edit User"
@page_active_3 = "active"
if request.post?
@user = User.find(params[:id])
@profile = @user.profile
verify_id(@user.id,
2006 Jun 16
0
Polling pop3 and adding emails to ticket system
Hi guys,
Im trying this code below to poll the pop3 mailbox, which i can do as a
standalone .rb file which copies the files to inbox/ but now im trying
to do the same for the controller to open the emails and add the content
to the ticket system.
but all i get is error, can somebody enlighten me?
class IncomingMail < ActionMailer::Base
def receive(email)
@ticket = Ticket.new