Partial Rendering of another controller's view ruby on rails - ruby-on-rails

I am using twitter Boostraps tabbable feature found here:
http://twitter.github.com/bootstrap/components.html#navs
And within this navigation content window, I am trying to render a view that displays a "course". This view found in views/courses/_show.html.erb looks like this:
<div class="center hero-unit">
<h1><%= #course.course_name %></h1>
<%= link_to 'New Question Set',new_answer_path(:course_ID => #course.id), :class => "btn btn-large btn-primary" %>
<%= link_to 'Launch Session!', edit_course_path, :class => "btn btn-large btn-primary" %>
</div>
I am trying to render it and failing with the following code in views/instructor/show.html.erb
<% courses.each do |c| %>
<div class="tab-pane" id="<%=c.course_name%>">
<%= render :partial => 'courses/show', :locals => {#course=>c} %>
</div>
I get the following error:
/app/views/courses/_show.html.erb:1: syntax error, unexpected '=',
expecting keyword_end ...tput_buffer = #output_buffer; =
local_assigns[:];show = loca... ... ^
/app/views/courses/_show.html.erb:1: syntax error, unexpected ']',
expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or
tSTRING_END ...tput_buffer; = local_assigns[:];show =
local_assigns[:show];... ...
saying it's failing at line 1 of my courses/_show.html.erb
My Course Controller looks like this:
class CoursesController < ApplicationController
# GET /courses
# GET /courses.json
def index
#courses = Course.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => #courses }
end
end
# GET /courses/1
# GET /courses/1.json
def show
#course = Course.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => #course }
end
end
# GET /courses/new
# GET /courses/new.json
def new
#course = Course.new(instructor_ID: params[:instructor_ID])
respond_to do |format|
format.html # new.html.erb
format.json { render :json => #course }
end
end
# GET /courses/1/edit
def edit
#course = Course.find(params[:id])
end
# POST /courses
# POST /courses.json
def create
#course = Course.new(params[:course])
respond_to do |format|
if #course.save
format.html { redirect_to #course, :notice => 'Course was successfully created.' }
format.json { render :json => #course, :status => :created, :location => #course }
else
format.html { render :action => "new" }
format.json { render :json => #course.errors, :status => :unprocessable_entity }
end
end
end
# PUT /courses/1
# PUT /courses/1.json
def update
#course = Course.find(params[:id])
respond_to do |format|
if #course.update_attributes(params[:course])
format.html { redirect_to #course, :notice => 'Course was successfully updated.' }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => #course.errors, :status => :unprocessable_entity }
end
end
end
Note: I have ommited some of the methods like delete in my controller to save space.
Any Ideas?!

In #course=>c change the # to a colon.

Related

Action Controller Exception w/ building "Multiple files upload with nested resource using Paperclip in Rails"

I'm trying to implement this rails cook solution for multiple images found here and am having issues with an action controller exception. I'm sure it's something I have over looked.
Here are my .rb files:
class Picture < ActiveRecord::Base
belongs_to :gallery
has_attached_file :image,
:path => ":rails_root/public/images/:id/:filename",
:url => "/images/:id/:filename"
do_not_validate_attachment_file_type :image
end
class Gallery < ActiveRecord::Base
has_many :pictures, :dependent => :destroy
end
And my pictures controller
class PicturesController < ApplicationController
before_action :set_picture, only: [:show, :edit, :update, :destroy]
# GET /pictures
# GET /pictures.json
def index
#pictures = Picture.all
end
# GET /pictures/1
# GET /pictures/1.json
def show
end
# GET /pictures/new
def new
#picture = Picture.new
end
# GET /pictures/1/edit
def edit
end
# POST /pictures
# POST /pictures.json
def create
#picture = Picture.new(picture_params)
#document = Document.new(:name) # :name is a symbol, not
respond_to do |format|
if #picture.save
format.html { redirect_to #picture, notice: 'Picture was successfully created.' }
format.json { render :show, status: :created, location: #picture }
else
format.html { render :new }
format.json { render json: #picture.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /pictures/1
# PATCH/PUT /pictures/1.json
def update
respond_to do |format|
if #picture.update(picture_params)
format.html { redirect_to #picture, notice: 'Picture was successfully updated.' }
format.json { render :show, status: :ok, location: #picture }
else
format.html { render :edit }
format.json { render json: #picture.errors, status: :unprocessable_entity }
end
end
end
# DELETE /pictures/1
# DELETE /pictures/1.json
def destroy
#picture.destroy
respond_to do |format|
format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_picture
#picture = Picture.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def picture_params
params[:picture]
end
end
And here is my form
<!-- app/views/galleries/_form.html.erb -->
<%= form_for #gallery, :html => { :class => 'form-horizontal', multipart: true } do |f| %>
<div class="control-group">
<%= f.label :name, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :name, :class => 'text_field' %>
</div>
</div>
<div class="control-group">
<%= f.label :description, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :description, :class => 'text_field' %>
</div>
</div>
<div class="control-group">
<%= f.label :pictures, :class => 'control-label' %>
<div class="controls">
<!-- The magic is coming ...look at my eyes....shazammmm -->
<!-- Use HTML5 multiple attribute to enable multiple selection
and pass back to controller all files as an array, ready
for paperclip!!
file_field_tag, since images is not a gallery attribute
-->
<%= file_field_tag "images[]", type: :file, multiple: true %>
</div>
</div>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
galleries_path, :class => 'btn btn-mini' %>
</div>
<% end %>
And here is my gallery controller
class GalleriesController < ApplicationController
before_action :set_gallery, only: [:show, :edit, :update, :destroy]
# GET /galleries
# GET /galleries.json
def index
#galleries = Gallery.all
end
# GET /galleries/1
# GET /galleries/1.json
def show
end
# GET /galleries/new
def new
#gallery = Gallery.new
end
# GET /galleries/1/edit
def edit
end
# POST /galleries
# POST /galleries.json
def create
#gallery = Gallery.new(gallery_params)
respond_to do |format|
if #gallery.save
if params[:images]
#===== The magic is here ;)
params[:images].each { |image|
#gallery.pictures.create(image: image)
}
end
format.html { redirect_to #gallery, notice: 'Gallery was successfully created.' }
format.json { render json: #gallery, status: :created, location: #gallery }
else
format.html { render action: "new" }
format.json { render json: #gallery.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /galleries/1
# PATCH/PUT /galleries/1.json
def update
respond_to do |format|
if #gallery.update(gallery_params)
format.html { redirect_to #gallery, notice: 'Gallery was successfully updated.' }
format.json { render :show, status: :ok, location: #gallery }
else
format.html { render :edit }
format.json { render json: #gallery.errors, status: :unprocessable_entity }
end
end
end
# DELETE /galleries/1
# DELETE /galleries/1.json
def destroy
#gallery.destroy
respond_to do |format|
format.html { redirect_to galleries_url, notice: 'Gallery was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_gallery
#gallery = Gallery.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def gallery_params
params.require(:gallery).permit(:gallery_id, :picture)
end
end
And here is my error
Your picture_params method may be causing the problem. Try modifying it to use the following format:
def picture_params
params.require(:picture).permit(:whitelisted, :attributes, :placed, :here)
end
You can use this repo provided in the tutorial you're following as a reference.
An additional reference on strong parameters.
Hope it helps!

Routing nested resources and matching controller

I've had a problem over the last few days getting my nested resources to create and display properly. There are tons of similar questions on StackOverflow and lots of blog posts on this, but they all seem to either deal with a older version of Rails or a different issue. I'm at the point where once I finally fix something, another error pops up. I've narrowed it down to me making a stupid mistake or typo being too inexperienced to notice.
I have a Jobs model that belongs to a Venue model. The venue works fine and I've even gotten as far as to be able to go to my nested Jobs index under each Venue and bring up the New and Edit forms, but going to 'Show' or creating a new Job caused an undefined method error. After a lot of searching I found plenty with the same problem and tried to implement their fixes, but now I'm getting a Routing Error.
Most of my confusing comes from when to leave off the #, when to use :venue_id instead of :id in params, etc. Every example I see seems to have a different way and I can't seem to make any of them work for me.
Any bump in the right direction would be extremely helpful.
The Routing Error
No route matches {:action=>"show", :controller=>"jobs", :venue_id=>#<Venue id: 1, name: "Burger Chef", city: "Chicago", state: "Illinois", areacode: 60614, created_at: "2013-02-05 21:33:41", updated_at: "2013-02-06 23:01:05", avatar_file_name: nil, avatar_content_type: nil, avatar_file_size: nil, avatar_updated_at: nil>}
routes.rb
Twist::Application.routes.draw do
resources :users
devise_for :users
resources :venues do
resources :jobs
end
end
jobs_controller.rb
class JobsController < ApplicationController
# GET /jobs
# GET /jobs.json
before_filter :get_venue
def get_venue
#venue = Venue.find(params[:venue_id])
end
def index
#jobs = #venue.jobs
respond_to do |format|
format.html # index.html.erb
format.json { render json: #jobs }
end
end
# GET /jobs/1
# GET /jobs/1.json
def show
#job = #venue.job.find(params[:id])
if params[:id]
#venue = Venue.where(:id => params[:id]).first
#jobs = #venue.job_url
else
#jobs = Jobs.all
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: #job }
end
end
# GET /jobs/new
# GET /jobs/new.json
def new
#job = #venue.jobs.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: #job }
end
end
# GET /jobs/1/edit
def edit
#job = #venue.job.find(params[:venue_id])
end
# POST /jobs
# POST /jobs.json
def create
#job = #venue.jobs.new(params[:job])
respond_to do |format|
if #job.save
format.html { redirect_to :action => :show, :id => #venue.id,
notice: 'Job was successfully created.' }
format.json { render json: [#venue, #job],
status: :created,
location: [#venue, #job] }
else
format.html { render action: "new" }
format.json { render json: #job.errors, status: :unprocessable_entity }
end
end
end
# PUT /jobs/1
# PUT /jobs/1.json
def update
#job = Job.find(params[:id])
respond_to do |format|
if #job.update_attributes(params[:job])
format.html { redirect_to #job, notice: 'Job was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: #job.errors, status: :unprocessable_entity }
end
end
end
# DELETE /jobs/1
# DELETE /jobs/1.json
def destroy
#job = Job.find(params[:id])
#job.destroy
respond_to do |format|
format.html { redirect_to jobs_url }
format.json { head :no_content }
end
end
end
venues_controller.rb
class VenuesController < ApplicationController
# GET /venues
# GET /venues.json
def index
#venues = Venue.all
if params[:name]
#user = User.where(:name => params[:name]).first
#venues = #user.venues
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: #venues }
end
end
# GET /venues/1
# GET /venues/1.json
def show
#venue = Venue.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: #venue }
end
end
# GET /venues/new
# GET /venues/new.json
def new
#venue = Venue.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: #venue }
end
end
# GET /venues/1/edit
def edit
#venue = Venue.find(params[:id])
#if session[:user_id] != #venue.user_id
# flash[:notice] = "Sorry, you cannot edit this venue."
# redirect_to(venues_path)
# =>end
end
# POST /venues
# POST /venues.json
def create
#venue = Venue.new(params[:venue_id])
respond_to do |format|
if #venue.save
format.html { redirect_to #venue, notice: 'Venue was successfully created.' }
format.json { render json: #venue, status: :created, location: #venue }
else
format.html { render action: "new" }
format.json { render json: #venue.errors, status: :unprocessable_entity }
end
end
end
# PUT /venues/1
# PUT /venues/1.json
def update
#venue = Venue.find(params[:id])
respond_to do |format|
if #venue.update_attributes(params[:venue])
format.html { redirect_to #venue, notice: 'Venue was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: #venue.errors, status: :unprocessable_entity }
end
end
end
# DELETE /venues/1
# DELETE /venues/1.json
def destroy
#venue = Venue.find(params[:id])
#venue.destroy
respond_to do |format|
format.html { redirect_to venues_url }
format.json { head :no_content }
end
end
end
job.rb
class Job < ActiveRecord::Base
attr_accessible :description, :name, :requirement, :venue_id
validates :name, :presence => true, :length => { :minimum => 3 }
belongs_to :venue
end
venue.rb
class Venue < ActiveRecord::Base
attr_accessible :areacode, :avatar, :city, :name, :state
has_many :jobs
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end
/jobs/show.html.erb
<p id="notice"><%= notice %></p>
<% #job = Job.find(param[:venue_id]) %>
<p>
<b>Name:</b>
<%= #job.name %>
</p>
<p>
<b>Company:</b>
<p><%= #venue.name %></p>
<p><%= link_to #job.venue.name, venue_path(#venue) %></p>
<p>
<b>Job:</b>
<%= #job.job_id %>
</p>
<p>
<b>Description:</b>
<%= #job.description %>
</p>
<p>
<b>Requirement:</b>
<%= #job.requirement %>
</p>
<%= link_to 'Edit', edit_venue_job_path(#venue, #job) %> |
<%= link_to 'Back', venue_jobs_path(#venue, #job) %>
**/jobs/index.html.erb**
<div class="usergrid">
<% jobs = #venue.jobs %>
<% #venue.jobs.each do |job| %>
<div class = "user venue">
<p>
<h2><%= link_to job.name, venue_job_path(#venue) %></h2>
<%= link_to 'Edit', edit_venue_job_path(#venue, job) %><br/>
<%= link_to 'Delete', venue_jobs_path(#venue, #job), :confirm => 'Are you sure?', :method => :delete %>
</div>
<% end %>
<div style="clear:both"></div>
</div>
<%= link_to 'New Job', new_venue_job_path(#venue) %>
I realize that...
This might be a really obvious fix, but being new to Rails there are definitely still some fundamentals that I don't completely understand.
If I posted too much or too little code please let me know, I'm not entirely sure how much is the least necessary for this.
There might be more than one error, there might be a lot of errors, and many of them could have been caused by me trying to fix this when I really didn't know what I was doing. I wanted to fix this myself, but I can't handle messing with it anymore when I'm really just making it worse.
I've tried messing with the routes, changing the actual links and routes, messing with scope, and as many of the common fixes for these errors that I could find and none of them seemed to help.
Thanks!
The error is saying that there is no route for the given params :
{:action=>"show", :controller=>"jobs", :venue_id=> "an_id"}
You can check that by running rake routes, and you'll see that, as jobs is nested under venue, the jobs#show controller actions needs two parameters : the venue_id (which is the job's 'parent') and the id which is the job id.
I quickly checked your code, and I think that one one of the things that causes the error is this line :
<h2><%= link_to job.name, venue_job_path(#venue) %></h2>
this should be
<h2><%= link_to job.name, venue_job_path(#venue, #job) %></h2>
Basically you'll get that kind of error, whenever you'll try to render a link to a job without providing the venue.
Let me know if you need more details or more information.

Ruby on Rails - Passing Parameters between methods

Routes File:
resources :tournaments do
resources :game, :only => [:new, :index, :create, :update, :destroy]
end
Rake Routes shows:
new_tournament_game GET /tournaments/:tournament_id/game/new(.:format) game#new
I call:
<td><%= link_to 'Add Game', new_tournament_game_path(tournament) %></td>
Game Model:
Takes me to the view game view with the URL:
http:// local host:3000/tournaments/2/game/new
And view:
<h1>New Game in <%= #tournament.name %> Tournament</h1>
<fieldset>
<%= form_for [:tournament, #game], :url => tournament_game_index_path do |f| %>
<table>
<td>
.... More fields .....
</td>
<div class="form-actions">
<%= f.submit "Create %>
</div>
<% end %>
When create is clicked it yields the error:
undefined method `game_url' for #<GamesController:0xb6131e40>
Questions:
Should I be using nested routes or hidden fields?
Do I need a separate tournament_game controller / view to handle the tournament game calls?
How do I get it to look for the correct create route when clicking the Create button?
When I want to have a relationship between two tables, do I only need the nested resource and the has_many / belongs_to calls or do I still need a foreign key column such as Tournament?
Sorry for all of the questions in one thread. Any help you can offer would be greatly appreciated!
Thank you.
Edit:
The error references line 39 which would be the line for the create controller.
class GamesController < ApplicationController
# GET /game
# GET /game.json
def index
#game = Game.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: #game }
end
end
# GET /game/1
# GET /game/1.json
def show
#game = Game.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: #game }
end
end
# GET /game/new
# GET /game/new.json
def new
#game = Game.new
#tournament = Tournament.find(params[:tournament_id])
end
# GET /game/1/edit
def edit
#game = Game.find(params[:id])
end
# POST /game
# POST /game.json
def create
#tournament = Tournament.find(params[:tournament_id])
#game = #tournament.game.build(params[:game])
respond_to do |format|
if params[:commit] != 'Cancel'
if #game.save
format.html { redirect_to #game, notice: 'Game was successfully created.' }
format.json { render json: #game, status: :created, location: #game }
format.json { render json: #game }
else
format.html { render action: "new" }
format.json { render json: #game.errors, status: :unprocessable_entity }
end
else
format.html { redirect_to #game, alert: 'Game was not updated.' }
end
end
end
# PUT /game/1
# PUT /game/1.json
def update
#game = Game.find(params[:id])
respond_to do |format|
if params[:commit] != 'Cancel'
if #game.update_attributes(params[:game])
format.html { redirect_to #game, notice: 'Game was successfully updated.' }
format.json { render json: #game }
else
format.html { render action: "edit" }
format.json { render json: #game.errors, status: :unprocessable_entity }
end
else
format.html { redirect_to #game, alert: 'Game was not updated.' }
end
end
end
# DELETE /game/1
# DELETE /game/1.json
def destroy
#game = Game.find(params[:id])
#game.destroy
respond_to do |format|
format.html { redirect_to game_url }
format.json { head :no_content }
end
end
end
Try this:
<%= form_for #game, :url => tournament_games_path(#tournament) do |f| %>
This will call the create method of games controller
Game Controller:
def create
#tournament = Tournament.find(params[:tournament_id])
#game = #tournament.games.build(params[:game])
if #game.save
flash[:success] = "Game created successfully"
redirect_to tournaments_path
else
render new_tournament_game_path
end
end
Routes:
resources :tournaments do
resources :games, :only => [:new, :index, :create, :update, :destroy]
end

undefined method `first_name'

Can anyone shed light on this for me?
undefined method `first_name' for #
Here is the show.html
<p id="notice"><%= notice %></p>
<div id="container">
<p>
<b>First name:</b>
<%= #artist.firstname %>
</p>
<p>
<b>Second name:</b>
<%= #artist.surname %>
</p>
<p>
<b>About:</b>
<%= #artist.about %>
</p>
<div id="comments">
<h2>Comments</h2>
<%= render :partial => "shared/comment", :collection => #artist.comments%>
</div
</div>
<%= render :partial => "image", :collection => #artist.images %>
<%= link_to 'Edit', edit_artist_path(#artist) %> |
<%= link_to 'Back', artists_path %>
<%= link_to 'show', images_path %>
Here is the partial
<div class="comment">
<p>
<span class="commentator"><%= comment.commentator.display_name %>
say's</span>
<%= comment.comment %>
</p>
</div
Here is the friend view
class Friends < ActiveRecord::Base
attr_accessible :firstname, :surname
has_many :comments, :as => :commentator, :class_name =>"Commentable"
def display_name
"#{self.firstname} #{self.surname}"
end
end
This is the friends controller
class FriendsController < ApplicationController
# GET /friends
# GET /friends.xml
def index
#friends = Friend.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => #friends }
end
end
# GET /friends/1
# GET /friends/1.xml
def show
#friend = Friend.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => #friend }
end
end
# GET /friends/new
# GET /friends/new.xml
def new
#friend = Friend.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => #friend }
end
end
# GET /friends/1/edit
def edit
#friend = Friend.find(params[:id])
end
# POST /friends
# POST /friends.xml
def create
#friend = Friend.new(params[:friend])
respond_to do |format|
if #friend.save
format.html { redirect_to(#friend, :notice => 'Friend was successfully created.') }
format.xml { render :xml => #friend, :status => :created, :location => #friend }
else
format.html { render :action => "new" }
format.xml { render :xml => #friend.errors, :status => :unprocessable_entity }
end
end
end
# PUT /friends/1
# PUT /friends/1.xml
def update
#friend = Friend.find(params[:id])
respond_to do |format|
if #friend.update_attributes(params[:friend])
format.html { redirect_to(#friend, :notice => 'Friend was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => #friend.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /friends/1
# DELETE /friends/1.xml
def destroy
#friend = Friend.find(params[:id])
#friend.destroy
respond_to do |format|
format.html { redirect_to(friends_url) }
format.xml { head :ok }
end
end
end
I am trying to make it so a friend can leave a comment on an artists page but I keep getting the above error.
I am very new to Ruby so I apologise if I have left anything out.
Basically, rails will look at the database to figure out what fields are on a model. So make sure your migrations have been run, and that first_name exists on the db table.
Also, Friends is plural. In rails, your table is plural (friends), your model is singular (Friend), and your controller is plural (FriendsController). It is best not to go against this convention. Try renaming the model and see what happens
This error related to database that first_name don't exist in your db.Run migration carefully.
You need line 2 of the Friend class to be attr_accessible :firstname, :surname so your views have access to the those variables.

Keeping devise flash message only

Hello i have a quick question. I get 2 flash messages, the devise one and the scaffolded one. How can i just have the Devise message in the beautiful flash box only?
Here is my code for creating Products:
def create
#product = current_user.products.build(params[:product])
#product.user = current_user
respond_to do |format|
if #product.save
format.html { redirect_to(#product, :notice => 'Product was successfully created.') }
format.xml { render :xml => #product, :status => :created, :location => #product }
else
format.html { render :action => "new" }
format.xml { render :xml => #product.errors, :status => :unprocessable_entity }
end
end
end
products/show.html.erb:
<p id="notice"><%= notice %></p>
<p><b>Name:</b><%= #product.name %> </p>
<p><b>Date:</b><%= #product.date %></p>
<p><b>Price:</b><%= number_to_currency(#product.price) %></p>
<p><b>User:</b><%= #product.user_id %></p>
<p><b>Latitude:</b><%= #product.latitude %></p>
<p><b>Longitude:</b><%= #product.longitude %></p>
<p><b>Tags:</b> <%= #product.tag_list %></p>
<%= link_to 'Edit', edit_product_path(#product) %> |
<%= link_to 'Back', products_path %>
Thank you!
Do you have a 'notice' in your application.html.erb as well?
<p id="notice"><%= notice %></p>
It may be best to put your notice & alert in there, instead of in all of your views anyway. Always good to refactor.
I think devise is sending a flash measage because of the way you are building a product. Instead you might try this:
def create
#product = Product.new(params[:product])
#product.user = current_user
respond_to do |format|
if #product.save
format.html { redirect_to(#product, :notice => 'Product was successfully created.') }
format.xml { render :xml => #product, :status => :created, :location => #product }
else
format.html { render :action => "new" }
format.xml { render :xml => #product.errors, :status => :unprocessable_entity }
end
end
end

Resources