search for: redirect_to_index

Displaying 20 results from an estimated 23 matches for "redirect_to_index".

2008 Apr 25
2
Can't Understand Why This Works
I have 3 methods: def add_to_cart # do some stuff redirect_to_index end def empty_cart # do some stuff redirect_to_index("your cart was emptied") end def redirect_to_index(msg = nil) flash[:notice] = msg if msg redirect_to :action => :index end How come the flash notice works if I''m setting msg = nil? For example, if I''...
2006 Jan 16
4
Creating two records at once
...er.registered_from_ip = request.remote_ip # Set the user''s status to a default of 2 # Status 1 = Admin # Status 2 = Member # Status 3 = General User @user.status = "2" @profile.user_id = @user.id if @user.save and @profile.save redirect_to_index("Thank you for registering #{@user.first_name} #{@user.last_name}") end end end The way it works now, the profiles table looks like this when a record is saved: mysql> select * from profiles; +----+--------+----------+---------+-------+---------+ | id | gender | homepage...
2007 Feb 13
1
Passing Arrays in recursive functions.
...t; " : " Not " flash[:notice] = "Task is#{words}finished" if request.xhr? then render :update do |page| ids_changed.each {|x| page.toggle "td_#{x}" page.toggle "menu_#{x}_done" } end else redirect_to_index end end def task_complete!(taskid, is_complete=true, ids_changed = []) @task = Task.find(taskid) val = is_complete ? 1 : 0 @task.update_attribute(:done, val) ids_changed.insert(-1,@task.id) if @task.completed? task_complete!(@task.parent, is_complete, ids_changed)...
2006 Jul 31
1
Adding new rows to a db
...t == nil Timesheet.create(:employee_id => ''1'', :cost_code_id => ''14'', :dept => ''007'', :ending_date => ''2006-07-15'') end redirect_to_index() end The create code does work, but I am trying to add the find to avoid duplicates. What is the format to mimic the where clause of a query? Thanks! -- Posted via http://www.ruby-forum.com/.
2007 Jan 27
0
Problems with implementation of dynamically updating scores
...if fair puts ''success'' @p.popular_score +=1 @p.save puts "add" @li = LineItem.new @li.product_id =params[:id] @li.list_id =-7ETwYBW1OEA@public.gmane.org @li.likeornot =1 @li.created_at = Time.now puts "line" @li.save redirect_to_index("推文成功") --> never worked, why? else redirect_to_index("一人只有一票唷") --> never worked, why? end end -------------------------------------------------------------------------------- In the view, I have a div displaying the score. <% if p...
2007 Oct 26
1
post_via_redirect - testing problem
...ut i can''t work out why: Here''s the action being tested - in case anyone recognises it, it''s based on the Depot app in Agile Web Dev with Rails. def checkout @in_checkout = true #don''t let user checkout with an empty cart if @cart.items.empty? redirect_to_index("Your cart is empty") else #see if the form is being submitted, ie if it''s a POST request if request.post? #make a new object with the form data @order = Order.create(:name => params[:name], :address => params[:a...
2009 Dec 13
20
Need help...NameError in InteractController#add_to_cart
Hi,I am developing a web app and am following the text-Agile web development.....Each time I click my "add to cart" button" i always get the  page below:I have double checked to see if i have errors in my code,there was none,please what do i need to do to proceed? NameError in InteractController#add_to_cartundefined local variable or method `find_cart'' for
2005 Dec 25
2
[repost] newbie questions
...gile Web Development with Rails''. I would like to extend the checkout screen, in such a way people can change the number of items they have selected in there cart. In my controller I have: def checkout @cart = find_cart @items = @cart.items if @items.empty? redirect_to_index("There''s nothing in your cart!") else @order = Order.new @address = Address.new end end I also created the following checkout.rhtml file: <% @page_title = "Checkout" -%> <%= error_messages_for(:order) %> <%= start_f...
2008 Jan 23
18
Not seeing the failure
...iven parameters and save" do post ''save_coupon'',{:coupon=>{:name=>@expectedName,:amount=>@expectedAmount}} end Here''s the controller method: def save_coupon coupon = Coupon.new(params[:coupon]) coupon.user = current_user coupon.save redirect_to_index "Coupon Added!" end And, I get the following failure: Mock ''Coupon_1008'' received unexpected message :user= with (#<User:0x221a3e8 @name="User_1009">) I''m sure that I''m missing something very simple, but I''ve been staring a...
2007 Jan 12
9
Nil object in E1 capture the order
I''m following the depot application in the rails bible Agile Web Development with Rails. In interation E1 NoMethodError in Admin#checkout Showing app/views/admin/checkout.rhtml where line #12 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.include? Extracted source (around line #12):
2007 Jan 29
6
RJS problem
...if fair puts ''success'' @p.popular_score +=1 @p.save puts "add" @li = LineItem.new @li.product_id =params[:id] @li.list_id =-7ETwYBW1OEA@public.gmane.org @li.likeornot =1 @li.created_at = Time.now puts "line" @li.save redirect_to_index("推文成功") --> never worked, why? else redirect_to_index("一人只有一票唷") --> never worked, why? end end -------------------------------------------------------------------------------- In the view, I have a div displaying the score. <% if p...
2006 Jul 31
4
RJS to find an element
I''m trying to implement a remove from cart method based on the examples in the second edition Agile book. I have everything working except for the RJS that removes items from the cart. Ideally what I''d like to do is highlight an element that I am deleting only if there is more than one of that particular item in the cart. If the item deleted is the only of
2005 Dec 14
9
Passing quantity in a shopping cart
I am using this line on my index.rhtml page to capture the quantity required of a particular item for a basic shopping cart app: <%= text_field ''line_item'', ''quantity'', {:size=>3} %> </td> but my next screen (a cart screen) doesn''t reflect what was entered in that text field when the item is added to the cart. That is,
2006 Aug 12
0
insert into database failing
...class QuoteLineItem < LineItem belongs_to :quote belongs_to :product end the section of code that actually fails is here (labelled) def send_quote @quote = Quote.new(params[:quote]) @quote.quote_line_items << @cart.items if @quote.save # <---- error occurs here @cart.empty! redirect_to_index(''Thanks for requesting a quote. We will be in contact with you shortly'') else redirect_to :action => ''details'' end end it fails with the following (note the values to be inserted are actually objects that have not been dereferenced: INSERT INTO line_item...
2006 Jul 02
1
Subject: Trying to Get Results from Form Element
...using the folowing controllers: admin_Controller application_Controller city_map_controller (with method: displayGMap) == Code Extract from city_map_controller == # Show a Google Map on a new page def displayGMap # @mapPoint = Gmap.find(params[:id]) # DBUG: Go back with report of what we found redirect_to_index("What the form got: |#{params[:id]}| |#{params[:mapPoint]}|") if params[:context] == :embedded render(:layout => false, :locals => { :mapPoint => @mapPoint}) end end I am using the following model: gmap.rb (containing class Gmap < ActiveRecord::Base) with...
2006 Jul 03
0
Page 129 of Agile Web Dev on Rails (or pg141 of pdf!)
...roduct) @items << current_item end current_item end Code in storecontroller.rb: # add a product to the cart def add_to_cart begin @product = Product.find(params[:id]) rescue logger.error("Attempt to access invalid product #{params[:id]}") redirect_to_index("Invalid product") else @cart = find_cart @current_item = @cart.add_product(@product) end end Code in _cart_item.rhtml: <% if cart_item == @current_item %> <tr id="current_item"> <% else %> <tr> <% end %> <td><%...
2005 Dec 23
0
newbie question
...gile Web Development with Rails''. I would like to extend the checkout screen, in such a way people can change the number of items they have selected in there cart. In my controller I have: def checkout @cart = find_cart @items = @cart.items if @items.empty? redirect_to_index("There''s nothing in your cart!") else @order = Order.new @address = Address.new end end I also created the following checkout.rhtml file: <% @page_title = "Checkout" -%> <%= error_messages_for(:order) %> <%= start_f...
2008 Feb 06
1
Try-Catch AWDWR P3.0, Sect9.2,Mid pg 121.
On page 118, file store_controller.rb, the "redirect_to_index" is added. At mid page 120, that line is removed. When the browser is first sent to the ":3000/store", the page displays properly. But when the Add to Cart button is clicked, the browser displays the text of a try-catch block (see below). There is no error message - the browser clear...
2007 Jan 15
5
ActionController::UnknownAction (No action responded to xxx)
...to access invalid product #{params[:id]}") flash[:notice] = " " redirect_to :action => :index else @list = List.new @list.add_line_item(@product,1) @list.name = 0 @list.user_id = session[:user_id] @list.created_at = Time.now @list.save redirect_to_index(" ") end # end end def unpush begin @product = Product.find(params[:id]) rescue logger.error("Attempt to access invalid product #{params[:id]}") flash[:notice] = " " redirect_to :action => :index else @list = List.new...
2006 Apr 19
6
undefined method `create_table'' for #<LoginController:0x5e60
...tance create_table(:suppliers) do |t| t.column :name, :string, :limit => 60 # Other fields here end end def authorize unless session[:user_id] flash[:notice] = "Please log in" redirect_to(:controller => "login", :action => "login") end end private def redirect_to_index(msg = nil) flash[:notice] = msg if msg redirect_to(:action => ''index'') end end with regards, Naveen -- Posted via http://www.ruby-forum.com/.