I'm relatively new to Rails. I'm trying to create an application that can allow users to create video game items and store them under their own users. I'm using the latest version of Rails and Devise.
Using scaffolding as a base, I created the Videogame model/controller within my application. After linking the video game models to the user who created them, it seems that any attributes that are entered into the creation form are not saving, or at the very least just not showing up on the videogames/index page. After trying to search around on Google and StackOverflow, I couldn't find any similar questions/guides to work with.
Any ideas on how to fix this? Any help for a Rails newbie would be greatly appreciated.
Below I've posted all files that may be relevant. Please let me know if anything else is needed. To see the whole project, see http://github.com/bmmart2/collection-manager
Image after item creation
Index page of two created items
Here is my controller:
class VideogamesController < ApplicationController
before_action :set_videogame, only: [:show, :edit, :update, :destroy]
# GET /videogames
# GET /videogames.json
def index
if user_signed_in?
#videogame = current_user.videogames.all
else
redirect_to :root
end
end
# GET /videogames/1
# GET /videogames/1.json
def show
end
# GET /videogames/new
def new
#videogame = current_user.videogames.new
end
# GET /videogames/1/edit
def edit
end
# POST /videogames
# POST /videogames.json
def create
#videogame = current_user.videogames.create(videogame_params)
respond_to do |format|
if #videogame.save
format.html { redirect_to #videogame, notice: 'Videogame was successfully created.' }
format.json { render :show, status: :created, location: #videogame }
else
format.html { render :new }
format.json { render json: #videogame.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /videogames/1
# PATCH/PUT /videogames/1.json
def update
respond_to do |format|
if #videogame.update(videogame_params)
format.html { redirect_to #videogame, notice: 'Videogame was successfully updated.' }
format.json { render :show, status: :ok, location: #videogame }
else
format.html { render :edit }
format.json { render json: #videogame.errors, status: :unprocessable_entity }
end
end
end
# DELETE /videogames/1
# DELETE /videogames/1.json
def destroy
#videogame.destroy
respond_to do |format|
format.html { redirect_to videogames_url, notice: 'Videogame was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_videogame
#videogame = Videogame.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def videogame_params
params.require(:videogame).permit(:title, :publisher, :platform, :year, :condition, :upc)
end
end
Videogame model:
class Videogame < ApplicationRecord
belongs_to :user
attr_accessor :title, :platform, :upc, :condition, :publisher, :year
end
Videogame db migration file:
class CreateVideogames < ActiveRecord::Migration[5.2]
def change
create_table :videogames do |t|
t.string :title
t.string :publisher
t.integer :condition
t.string :platform
t.string :year
t.string :upc
t.timestamps
end
add_index :videogames, :user_id
end
end
add_user_refs_to_videogame migration:
class AddUserRefsToVideogame < ActiveRecord::Migration[5.2]
def change
add_reference :videogames, :user, foreign_key: true
end
end
Edit: show view for video game
<p id="notice"><%= notice %></p>
<p>
<strong>Title:</strong>
<%= #videogame.title %>
</p>
<p>
<strong>Publisher:</strong>
<%= #videogame.publisher %>
</p>
<p>
<strong>Platform:</strong>
<%= #videogame.platform %>
</p>
<p>
<strong>Year:</strong>
<%= #videogame.year %>
</p>
<p>
<strong>Condition:</strong>
<%= #videogame.condition %>
</p>
<p>
<strong>Upc:</strong>
<%= #videogame.upc %>
</p>
<%= link_to 'Edit', edit_videogame_path(#videogame) %> |
<%= link_to 'Back', videogames_path %>
I believe the attr_accessor line in your videogame.rb file is causing the problem. Try deleting it and see if that fixes the problem.
Related
I checked various solutions that are available, but none seem to address the issue that I am having with my project. I am trying to allow the user to create reviews through the EmployerReview model for the employer. When I pass the employer_id to the form_for in the employer_reviews_controller it claims that it cannot find an employer without an ID. The id is being passed with the #employer instance variable. I don't get why it's not working. Lastly, I am using friendly_id, and it shows at the end of the new employer review address employer_reviews/new.bryers. How can I stop this error from occurring?
schema
create_table "employer_reviews", force: :cascade do |t|
t.text "review_body"
t.string "review_title"
t.bigint "user_id"
t.bigint "employer_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["employer_id"], name: "index_employer_reviews_on_employer_id"
t.index ["user_id"], name: "index_employer_reviews_on_user_id"
end
employer_review.rb
class EmployerReview < ApplicationRecord
belongs_to :employer
belongs_to :user
end
user.rb
class User < ApplicationRecord
has_many :employer_reviews, dependent: :destroy
end
employer.rb
class Employer < ApplicationRecord
extend FriendlyId
friendly_id :username, use: [:slugged, :finders]
has_many :employer_reviews, dependent: :destroy
end
employers_controller.rb
class EmployersController < ApplicationController
before_action :set_employer, only: [:show]
def show
impressionist(#employer)
end
private
def set_employer
#employer = Employer.find(params[:id])
end
end
employer_reviews_controller.rb
class EmployerReviewsController < ApplicationController
before_action :set_employer_review, only: [:show, :edit, :update, :destroy]
before_action :set_employer
before_action :authenticate_user!
# GET /employer_reviews/1
# GET /employer_reviews/1.json
def show
end
# GET /employer_reviews/new
def new
#employer_review = EmployerReview.new
end
# GET /employer_reviews/1/edit
def edit
end
# POST /employer_reviews
# POST /employer_reviews.json
def create
#employer_review = EmployerReview.new(employer_review_params)
#employer_review.user_id = current_user.id
#employer_review.employer_id = #employer_review.id
respond_to do |format|
if #employer_review.save
format.html {redirect_to #employer_review, notice: 'Employer review was successfully created.'}
format.json {render :show, status: :created, location: #employer_review}
else
format.html {render :new}
format.json {render json: #employer_review.errors, status: :unprocessable_entity}
end
end
end
# PATCH/PUT /employer_reviews/1
# PATCH/PUT /employer_reviews/1.json
def update
respond_to do |format|
if #employer_review.update(employer_review_params)
format.html {redirect_to #employer_review, notice: 'Employer review was successfully updated.'}
format.json {render :show, status: :ok, location: #employer_review}
else
format.html {render :edit}
format.json {render json: #employer_review.errors, status: :unprocessable_entity}
end
end
end
# DELETE /employer_reviews/1
# DELETE /employer_reviews/1.json
def destroy
#employer_review.destroy
respond_to do |format|
format.html {redirect_to employer_reviews_url, notice: 'Employer review was successfully destroyed.'}
format.json {head :no_content}
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_employer_review
#employer_review = EmployerReview.find(params[:id])
end
def set_employer
#employer = Employer.find(params[:employer_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def employer_review_params
params.require(:employer_review).permit([:review_title, :review_body])
end
end
employer show.html.erb
<%= link_to 'Write a review', new_employer_review_path(#employer) %>
routes.rb
resources :employers
resources :employer_reviews
review form
<%= simple_form_for([#employer, #employer_review]) do |f| %>
<%= f.error_notification %>
<div class="form-group">
<label>Review Title</label>
<%= f.input :review_title, class: 'form-control', placeholder: 'Add a review title' %>
</div>
<div class="form-group">
<label>Tell us about your experience</label>
<%= f.input :review_body, :as => :text, :input_html => { 'rows' => 5, 'cols' => 10 }, class: 'form-control', placeholder: 'Add a review title' %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
UPDATE 1:
I'm receiving the error below when I use both #employer_review and #employer in the simple_form.
ActionView::Template::Error (undefined method `model_name' for nil:NilClass):
1: <%= simple_form_for([#employer_review, #employer]) do |f| %>
2: <%= f.error_notification %>
3: <div class="form-group">
4: <label>Review Title</label>
app/views/employer_reviews/_form.html.erb:1:in `_app_views_employer_reviews__form_html_erb__154747394_155744960'
app/views/employer_reviews/new.html.erb:3:in `_app_views_employer_reviews_new_html_erb__376973310_155859880'
Processing by ExceptionHandler::ExceptionsController#show as HTML
Parameters: {"employer_id"=>"test_employer"}
Completed 500 Internal Server Error in 404ms (ActiveRecord: 0.0ms)
Your employers and employer_reviews resources are not nested. It means employer_id param in your EmployerReviewsController is nil (if it is not set explicitly in query string). Calling set_employer filter has no effect and #employer instance variable is nil. That's why simple_form cannot find that employer (without id).
You either have to turn employer_reviews to nested resource of employers, or remove #employer variable from EmployerReviewsController and use simple_form solely for #employer_review.
I am building an app that allows a user to create a contest. Each contest has many questions and each contests has many entries. Each entry has many answers and each question has many answers. Here are my models:
class Answer < ActiveRecord::Base
belongs_to :entry
belongs_to :question
end
class Contest < ActiveRecord::Base
has_many :entries
has_many :questions
end
class Entry < ActiveRecord::Base
belongs_to :contest
has_many :answers
accepts_nested_attributes_for :answers, allow_destroy: true
end
class Question < ActiveRecord::Base
has_many :answers
belongs_to :contest
end
Everything works except for when I try to create an entry. I get a "param is missing or the value is empty: entry" error. Here is my controller:
class EntriesController < ApplicationController
before_action :set_entry, only: [:show, :edit, :update, :destroy]
before_action :set_contest
# GET /entries
# GET /entries.json
def index
#entries = Entry.all
end
# GET /entries/1
# GET /entries/1.json
def show
end
# GET /entries/new
def new
#entry = Entry.new
end
# GET /entries/1/edit
def edit
end
# POST /entries
# POST /entries.json
def create
#entry = Entry.new(entry_params)
#entry.contest = #contest
respond_to do |format|
if #entry.save
format.html { redirect_to #entry, notice: 'Entry was successfully created.' }
format.json { render :show, status: :created, location: #entry }
else
format.html { render :new }
format.json { render json: #entry.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /entries/1
# PATCH/PUT /entries/1.json
def update
respond_to do |format|
if #entry.update(entry_params)
format.html { redirect_to #entry, notice: 'Entry was successfully updated.' }
format.json { render :show, status: :ok, location: #entry }
else
format.html { render :edit }
format.json { render json: #entry.errors, status: :unprocessable_entity }
end
end
end
# DELETE /entries/1
# DELETE /entries/1.json
def destroy
#entry.destroy
respond_to do |format|
format.html { redirect_to entries_url, notice: 'Entry was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_entry
#entry = Entry.find(params[:id])
end
def set_contest
#contest = Contest.find(params[:contest_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def entry_params
params.require(:entry).permit(:contest_id, answers_attributes: [:id, :content, :entry_id, :question_id, :_destroy])
end
end
And here is my entry form:
<%= simple_form_for([#contest, #entry]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<h3>Questions</h3>
<%= simple_fields_for :answers do |ff| %>
<% #contest.questions.each do |question| %>
<h4><%= question.content %></h4>
<%= ff.input :content, input_html: {class: 'form-control'} %>
<% end %>
<% end %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
I am still working on the logic but am perplexed as to why the entry form is giving me this error. Any help would be appreciated!
UPDATE
In the Rails Guide example they show the new action as:
def new
#person = Person.new
2.times { #person.addresses.build}
end
Do I need to build the answer objects in my new action? I'm not sure... I tried it but it didn't work. I feel like that can't be the problem though as the error is coming from the entry_params method
You should be adding this line to your new action.
#entry.answers.build
And change this line
<%= simple_fields_for :answers do |ff| %>
to
<%= f.simple_fields_for :answers do |ff| %>
Apologies if this has already been answered but I can't find anything that can help me. I am a newbie with Rails so please be gentle :D
I have been pulling my hair out trying to get nested forms working, I am sure I got nested forms working using Rails 3 and the railscasts demo last year, but Rails 4 is beating me.
Looking at the log, the query is being run to pull the data for the associated table, but nothing is rendered in the form.
I have read many web sites, but none have helped so far and I don't know where to start. The latest article I have followed is this http://www.createdbypete.com/articles/working-with-nested-forms-and-a-many-to-many-association-in-rails-4/
Still nothing being rendered in the view.
Where do I start debugging this, maybe my Rails install is broken?? But I am probably missing something crucial.
Thanks,
Royce
Edit - I have added some of the controllers and the view in question
surveys_controller.rb
class SurveysController < ApplicationController
before_action :set_survey, only: [:show, :edit, :update, :destroy, :answers]
# GET /surveys
# GET /surveys.json
def index
#surveys = Survey.all
end
# GET /surveys/1
# GET /surveys/1.json
def show
end
# GET /surveys/new
def new
#survey = Survey.new
end
# GET /surveys/1/edit
def edit
end
# POST /surveys
# POST /surveys.json
def create
#survey = Survey.new(survey_params)
respond_to do |format|
if #survey.save
format.html { redirect_to #survey, notice: 'Survey was successfully created.' }
format.json { render :show, status: :created, location: #survey }
else
format.html { render :new }
format.json { render json: #survey.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /surveys/1
# PATCH/PUT /surveys/1.json
def update
respond_to do |format|
if #survey.update(survey_params)
format.html { redirect_to #survey, notice: 'Survey was successfully updated.' }
format.json { render :show, status: :ok, location: #survey }
else
format.html { render :edit }
format.json { render json: #survey.errors, status: :unprocessable_entity }
end
end
end
# DELETE /surveys/1
# DELETE /surveys/1.json
def destroy
#survey.destroy
respond_to do |format|
format.html { redirect_to surveys_url, notice: 'Survey was successfully destroyed.' }
format.json { head :no_content }
end
end
def answers
#participants = Participant.all
#questions = #survey.questions
end
private
# Use callbacks to share common setup or constraints between actions.
def set_survey
#survey = Survey.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def survey_params
params.require(:survey).permit(:name,
:questions_attributes => [:id, :content,
:answers_attributes => [:id, :content, :participant_id]
])
end
end
participents_controller.rb
class ParticipantsController < ApplicationController
before_action :set_participant, only: [:show, :edit, :update, :destroy]
# GET /participants
# GET /participants.json
def index
#participants = Participant.all
end
# GET /participants/1
# GET /participants/1.json
def show
end
# GET /participants/new
def new
#participant = Participant.new
end
# GET /participants/1/edit
def edit
end
# POST /participants
# POST /participants.json
def create
#participant = Participant.new(participant_params)
respond_to do |format|
if #participant.save
format.html { redirect_to #participant, notice: 'Participant was successfully created.' }
format.json { render :show, status: :created, location: #participant }
else
format.html { render :new }
format.json { render json: #participant.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /participants/1
# PATCH/PUT /participants/1.json
def update
respond_to do |format|
if #participant.update(participant_params)
format.html { redirect_to #participant, notice: 'Participant was successfully updated.' }
format.json { render :show, status: :ok, location: #participant }
else
format.html { render :edit }
format.json { render json: #participant.errors, status: :unprocessable_entity }
end
end
end
# DELETE /participants/1
# DELETE /participants/1.json
def destroy
#participant.destroy
respond_to do |format|
format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_participant
#participant = Participant.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def participant_params
params.require(:participant).permit(:name)
end
end
application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
answers.html.erb
<h1><%= #survey.name %> Answers</h1>
<%= form_for(#survey) do |f| %>
<% #participants.each do |participant| -%>
<h3><%= participant.name %></h3>
<table>
<thead>
<tr>
<td>Questions</td>
<td>Answer</td>
</tr>
</thead>
<tbody>
<% #questions.each do |question| -%>
<tr>
<td><%= question.content %></td>
<td>
<%= f.fields_for :questions, question do |q| -%>
<%= q.fields_for :answers, question.answers.find_or_initialize_by(participant: participant) do |a| -%>
<%= a.text_area :content %>
<%= a.hidden_field :participant_id, participant.id %>
<% end -%>
<% end -%>
</td>
</tr>
<% end -%>
</tbody>
</table>
<% end -%>
<div class="actions">
<%= f.submit %>
</div>
<% end -%>
As you're new with Rails, let me explain how nested forms work for you!
--
Nested
Nested forms are not actually nested at all - they are associative forms.
You must remember that Rails (by virtue of being built on Ruby) is an object orientated framework. OOP (object orientated programming) is not just a buzzword - it's a fundamental core construction for your application & how it hands input / execution.
The problem many people have is they don't realize the true nature of Rails, and consequently become confused about how its many features work. If you appreciate that everything you do in Rails should be constructed around objects, life gets much simpler!
--
Form
With this in mind, you can begin to appreciate the role of objects throughout Rails, to the degree that you need to build / invoke objects for every element of your Rails application, including your form:
#app/models/survey.rb
Class Survey < ActiveRecord::Base
has_many :questions
accepts_nested_attributes_for :questions
end
#app/controllers/surveys_controller.rb
Class SurveysController < ApplicationController
def new
#survey = Survey.new
#survey.questions.build #-> very important
end
end
#app/views/surveys/new.html.erb
<%= form_for #survey do |f| %>
...
<%= f.fields_for :questions do |q| %>
<%= q.text_field :title %>
<% end %>
<%= f.submit %>
<% end %>
This should create a form which allows you to pass associative data through to your child model. There are several important elements to consider:
You need to include accepts_nested_attributes_for in your "parent" model
You need to build your associative objects
You need to populate your form with the relative objects
By following this simple pattern, you'll be able to populate the nested form that you wish to show in the view
Try to use the following code:
<%= f.fields_for :questions do |q| -%>
<%= q.fields_for :answers, q.object.answers.find_or_initialize_by(participant: f.object.participant) do |a| -%>
<%= a.text_area :content %>
<%= a.hidden_field :participant_id, participant.id %>
<% end -%>
<% end -%>
and make sure that you render to answers.html.erb, you have accepts_nested_attributes_for :questions in survey.rb file, and accepts_nested_attributes_for :answers in question.rb file
Have you got accepts_nested_attributes_for :question in your survey model? And the same for the answer model?
Hi i'm very new to rails and any help will much appreciated. I am trying to implement the thumbs_up GEM. I have read the documentation but still find it challenging to implement it fully.
what i would like is the display of an increasing figure when a user clicks on the thumbs_up image and vice-versa when a user clicks on thumbs_down image
by figure i mean: if a user clicks the image thumbs_up you see a figure of 1, if another user clicks the image thumbs_up the figure increases to 2 [displaying 2 users have liked the event giving it a thumbs_up]
Any advise along side with an explanation will be helpful - below is the stage i have reached
i have a.) run g thumbs_up & b.) rake db:migrate
Models:
#Event.rb
class Event < ActiveRecord::Base
belongs_to :user
acts_as_voteable
end
#User.rb
class User < ActiveRecord::Base
has_many :events, dependent: :destroy
acts_as_voter
end
Controller
class EventsController < ApplicationController
before_action :set_event, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!
def index
#events = Event.order(:date)
end
def show
#commentable = #event
#comments = #commentable.comments
#comment = Comment.new
end
def new
#event = Event.new
end
def edit
end
def create
#event = Event.new(event_params)
#event.user = current_user
respond_to do |format|
if #event.save
format.html { redirect_to #event, notice: 'Event was successfully created.' }
format.json { render :show, status: :created, location: #event }
else
format.html { render :new }
format.json { render json: #event.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if #event.update(event_params)
format.html { redirect_to #event, notice: 'Event was successfully updated.' }
format.json { render :show, status: :ok, location: #event }
else
format.html { render :edit }
format.json { render json: #event.errors, status: :unprocessable_entity }
end
end
end
def destroy
#event.destroy
respond_to do |format|
format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }
format.json { head :no_content }
end
end
def vote_for
#event = Event.find(params[:id])
current_user.vote_for(#event)
respond_to do |format|
format.js
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_event
#event = Event.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def event_params
params.require(:event).permit(:name, :description, :date, :time, :city, :price, :user_id)
end
end
Views: app/views/events/show.html.erb
<p>
<strong>Name:</strong>
<%= #event.name %>
</p>
<p>
<strong>Description:</strong>
<%= #event.description %>
</p>
<p>
<%=link_to image_tag('thumbs_up', :border => 0), vote_for_event_path(#event), :remote => true %>
<%=link_to image_tag('thumbs_down', :border => 0), vote_against_event_path(#event), :remote => true %>
</p>
Routes:
Rails.application.routes.draw do
devise_for :users
resources :events do
resources :comments, only: [:create, :destroy]
member do
post :vote_for, :vote_against
end
end
end
To show the votes in your view, use the votes_for method and votes_against method.
For example in your view add these lines:
<p>
<strong>Votes For:</strong>
<%= #event.votes_for %>
</p>
<p>
<strong>Votes Against:</strong>
<%= #event.votes_against %>
</p>
Because you are learning Rails, I suggest you try using basic HTML links instead of AJAX links:
<%=link_to image_tag('thumbs_up', :border => 0), vote_for_event_path(#event) %>
<%=link_to image_tag('thumbs_down', :border => 0), vote_against_event_path(#event) %>
A basic link can help you see what's happening, and your controller will reload the entire page.
When you get the basic links working, then read about AJAX, and how to use the Rails link_to with remote: true to update an HTML div.
There are various ways to accomplish this: you can read about using Rails responders, or using coffescript, or using jQuery to attach a link handler.
There are also various user interface solutions, such as updating the vote immediately because you know the original vote and you can increment the vote immediately on the client side.
Here's a related StackOverflow question that has a bunch of good answers and discussion about remote_to and replacing a div: rails link_to :remote
I have a formfield in my form like this:
<div class="tags">
<%= f.label :tags %>
<%= f.text_area :tags %>
</div>
I ran a migration like this:
class AddTagsToIssues < ActiveRecord::Migration
def change
add_column :issues, :tags, :text
end
end
When i save, the new row is added to db, but tags = nil, although I typed something like 'test' in de text_area
in my development log I have:
Unpermitted parameters: tags
I have tried whitelisting in my controller:
def create
#issue = Issue.new(issue_params)
Issue.new(params.permit(:tags))
but this doesn't work.
Update for follow up question:
Full create method:
def create
def issue_params
params.require(:issue).permit(:tags)
end
#issue = Issue.new(issue_params)
Issue.new(params.permit(:tags))
respond_to do |format|
if #issue.save
format.html { redirect_to #issue, notice: 'Issue was successfully created.' }
format.json { render action: 'show', status: :created, location: #issue }
else
format.html { render action: 'new' }
format.json { render json: #issue.errors, status: :unprocessable_entity }
end
end
end
The model:
class Issue < ActiveRecord::Base
belongs_to :project
end
The table create query:
class CreateIssues < ActiveRecord::Migration
def change
create_table :issues do |t|
t.string :title
t.text :description
t.integer :no_followers
t.timestamps
end
end
end
So with this I don't have permission problems, that only happened with the later adding of the tags, and then only with the tags.
tags is being set as nil because you have not permitted it.
Permit tags in the issue_params method as below:
def issue_params
params.require(:issue).permit(:tags,...)
end
where, ... refers to other fields in model Issue.
Your create action should look something like this,
def create
#issue = Issue.new(issue_params) ## issue_params called
if #issue.save ## save the record
redirect_to #issue, notice: 'Issue was successfully created.'
else
render action: 'new'
end
end