Displaying 20 results from an estimated 30000 matches similar to: "retrieve previous id"
2006 Jun 13
4
When saving parent fails, children will still be updated
Hi all,
When submitting a master/detail form I first want to handle the children 
before saving the parent.
There are has_many and belongs_to relations between the parent and the 
children, so I can edit the children using (psuedo-)code like:
child.destroy for deleting, child.update_attributes for updating and 
@parent.children.push(child) for adding child-records.
I update the parent by using:
2006 Jul 10
9
ROR questions
Hi,
?
I''m a Ruby on Rails newbie.? I''ve been tasked with building our office''s first ROR application, and I am the only one working on it, so I am muddling through with a couple of books...? Moving along slowly but need some discussion time with some people who KNOW it and can maybe offer some answers to questions I haven''t found in my books.
?
First - what is
2006 May 08
4
set forign key
hi,
got a small problem below and not to sure how to overcome this using 
rails
two tables involved with this projects and quotes
each project has a field quote_id as a forign field.
When a user is ready to upload a quote they are linked to quotes/new 
from the show  project page. Once the quote is uploaded how can I then 
set the quote_id field with the correct key?
-- 
Posted via
2006 Jun 01
5
flash not clearing after display
(Rails 1.1, Ruby 1.8.4)
In the layout for one of my controllers, I have a tag to display a flash 
message (copied from AWDWR), like this:
     <div id="data">
        <% if @flash[:notice] -%>
          <div id="notice"><%= @flash[:notice] %></div>
        <% end -%>
        <%= @content_for_layout %>
      </div>
If the
2006 Mar 04
7
Get ID after save
This is simple (I am sure) but how do you get the id of the inserted 
element after the element has been save?
I thought it was something like this:
@product = Product.new(params[:product]
if @product.save
  add_image(product.id, params["image"])
  flash[:notice] = ''Product was successfully created.''
  redirect_to :action => ''list_products''
end
2006 Mar 24
6
login forms , redirect_to and ajax-scaffold problems
Hi,
I have a standard type authentication technique direct from  AWDWR, so there is a
 before_filter :authorize_employee, :except => :login in my employees_controller.rb
the authorize_employee is in application.rb
     def authorize_employee
        unless session[:employee_id]
            flash[:notice] = "Please log in"
            # save the URL the user requested so we can hop
2006 Oct 25
4
Flash messages stay up too long
I run a check on the address line parameters to make sure the user isn''t 
passing my list method a :year to search for that does not exist in the 
database, which would create null pointer exceptions.  I then splash a 
flash message telling the user that the year doesn''t exist in the 
database.  Then, if the user enters another year into the command line 
as an argument for the
2006 Jun 15
8
rails saves it to the database and I don''t want to
Hello:
I am developing a web application to book machines for an event.
so I have an event model
class Event < ActiveRecord::Base
    has_many :datetimes
...
end
and a datetime model
class Datetime < ActiveRecord::Base
    belongs_to :event
...
end
I have developed a view with the event information and information for 
the datetimes. and in the event_controller when I capture a datetime I 
2006 May 10
2
gain value from form
I have the following form
<%= start_form_tag :action => ''rejectQuoteSave'', :id => @project %>
<p><label for="offer_reason_rejected"><span class="required">* 
</span>Reason</label><br/>
<%= text_area ''offer'', ''reason_rejected''  %></p>
<%= submit_tag
2006 Jul 07
4
need help with some ugly code - is there a better way?
Hi,
In my user_controller.rb, I have the following method, which is supposed 
to send the user to their profile, dependng on what "role" they are (the 
roles correspond to the other controllers: venue, band, fan):
    def login
      if request.post?
        if session[:user_id] = User.authenticate(params[:user][:login], 
params[:user][:password])
          flash[:message]  =
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 May 09
7
going crazy!!!!!! ActiveRecord::StatementInvalid in Project
any suggestions on why I am gaining this error.
ActiveRecord::StatementInvalid in ProjectsController#create
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 projects (`name`, 
`date_created`, `quote_id`, `client_id`, `description`, `user_id`) 
2007 Jul 26
6
response.should_not redirect_to
Hey,
May be it is just too deep night over here and I''m missing something  
though I got this failure on {{{response.should_not redirect_to}}}:
''QueuesController should allow authenticated user to access ''show''''  
FAILED
Matcher does not support should_not.
See Spec::Matchers for more information
about matchers.
Also I''ve found this in
2006 Aug 07
3
simple if - then question
hi, could somebody tell me the difference between:
if not params[:id]
      flash[:notice] = blabla''
      redirect_to(:controller =>"calendar", :action => ''index'')
end
and:
if params[:id] == nil
      flash[:notice] = blabla''
      redirect_to(:controller =>"calendar", :action => ''index'')
end
the first one
2006 Dec 30
1
redirect_to(:action => ''foo'') and return
I''m not sure why this is happening, but if I do this in a controller
    unless @variation && @variation.quantity > 0
      flash[:error] = "Sorry, that product is currently not available."
      redirect_to(:action => ''error'') and return
    end
rspec tells me
  2)
  ActionController::DoubleRenderError in ''The Carts controller with an
2006 Feb 08
1
Weird validation issue
Hi,
I''m having a weird validation issue. Validation isn''t working for
certain attributes and, for some reason, it''s also affecting things
outside of validation.
For campers on certain camp types, we require some information about
their school. I tried to validate  the information this way:
validates_presence_of :school_type, :if => Proc.new { |c|
!c.booking.nil?
2006 Feb 21
5
Abstracting ownership verification out of Controller
Right now I have a controller for "events" that belong to a specific
user.  I only want the creator to be able to edit or delete the event.
I''ve got the proper foreign keys set up.
I''ve finally arrived at the point where I can take baby steps with
code, but looks like my first steps are in flagrant violation of the
DRY principle.
Here''s what I have so far in
2006 Jul 22
2
redirect_to error
Hi,
I have a redirect_to statement in a method that I would like to  have  
at the end of the method to take you  to a ''Success'' page if  
everything works.
When I hit the redirect_to statement, ( redirect_to :action =>  
''show_success'' )
I get this in the browser:
Application error
Rails application failed to start properly"
The development.log
2006 Jul 17
2
error_messages_for ?
Hi,
I can''t list error_messages in my Form ??, and all the formfields are 
reset ...(I think my redirect :back clean everything, formfield and 
error_messages ...), only my flash[:notice] is ok....
I would like to use the "error_messages_for" tag to add a simple red * 
on my textfiled if a problem occurs ...
thanks for help
arnaud
here are the basics steps to check that
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}) %>