On Jun 9, 2:41 pm, anon_comp <[email protected]> wrote: > This is slightly tied with my previous post. I wasn't sure if I was > supposed to make another message in there, so I made a new post. > > So in my previous post I accidentally asked a pure ruby question about > gsub which I'll be using in this question. > > Anyways, what I want to do is to take a single parameter from user's > input in the Form_for and run it through the gsub code [ @file_cut = > order.gsub(/[\w ! # $ % ^ & * + -]+\.doc$/, '*.doc) ] when the user > submits the form. The parameter will still be stored in the database > so I don't think test_field_tag, etc. will help me unless you think > otherwise. Also, I'm hoping not to use javascript in my code. > > Here's my code: > > orders_controller.rb > ------------------------------------------------------------ > class OrdersController < ApplicationController > # GET /orders > # GET /orders.xml > def index > @orders = Order.all > > respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @orders } > end > end > > # GET /orders/1 > # GET /orders/1.xml > def show > @order = Order.find(params[:id]) > > #...@try = params[:file] > # A failed attempt > > respond_to do |format| > format.html # show.html.erb > format.xml { render :xml => @order } > end > end > > # GET /orders/new > # GET /orders/new.xml > def new > @order = Order.new > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @order } > end > end > > # POST /orders > # POST /orders.xml > def create > @order = Order.new(params[:order]) > > #order = params[:file] > #...@file_cut = order.gsub(/[\w ! # $ % ^ & * + -]+\.doc$/, '*.doc) > #have tried to implement the code here > > respond_to do |format| > if @order.save > format.html { redirect_to(@order, :notice => "Order was > successfully created.") } > format.xml { render :xml => @order, :status > => :created, :location => @order } > #/display > else > format.html { render :action => "new" } > format.xml { render :xml => @order.errors, :status > => :unprocessable_entity } > end > end > end > > # DELETE /orders/1 > # DELETE /orders/1.xml > def destroy > @order = Order.find(params[:id]) > @order.destroy > > respond_to do |format| > format.html { redirect_to(orders_url) } > format.xml { head :ok } > end > end > end > > new.html.erb > ------------------------------------------------------------ > <h1> > New Order > </dh1> > > <% form_for(@order) do |f| %> > <%= f.error_messages %> > > <p> > <%= f.label :name, "Your Name" %><br /> > <%=h f.text_field :name %> > </p> > <p> > <%= f.label :file%><br /> > <%=h f.file_field :file%> > </p> > <p> > <%= f.label :email, "Your Email" %><br /> > <%=h f.text_field :email %> > </p> > <p> > <%= f.submit 'Create' %> > </p> > <% end %> > > <%= link_to 'Back', orders_path %> > > Thank you for taking the time to read, > Anon_comp
Problem solve. Just did multiple redirects. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

