https://stackoverflow.com/questions/26778712/param-is-missing-or-the-value-is-empty-credit-cardror-ecommerce
Getting the error below. I understand what the issue is, but not sure how to fix it?
when i add credit card it says parameter is empty.
I thought I had set everything right, but I hope someone can help me find what I am doing wrong or missing, thanks!
I am getting this error:
param is missing or the value is empty::credit_card
controller:
class Myaccount::CreditCardsController < Myaccount::BaseController def index @credit_cards = current_user.payment_profiles end def show @credit_card = current_user.payment_profiles.find(params[:id]) end def new @credit_card = current_user.payment_profiles.new end def create @credit_card = current_user.payment_profiles.new(allowed_params) if @credit_card.save flash[:notice] = "Successfully created credit card." redirect_to myaccount_credit_card_url(@credit_card) else render :action => 'new' end end def edit @credit_card = current_user.payment_profiles.find(params[:id]) end def update @credit_card = current_user.payment_profiles.find(params[:id]) if @credit_card.update_attributes(allowed_params) flash[:notice] = "Successfully updated credit card." redirect_to myaccount_credit_card_url(@credit_card) else render :action => 'edit' end end def destroy @credit_card = current_user.payment_profiles.find(params[:id]) @credit_card.inactivate! flash[:notice] = "Successfully destroyed credit card." redirect_to myaccount_credit_cards_url end private def allowed_params #params.require(:payment_profile).permit! params.require(:credit_card).permit(:address_id, :month, :year, :cc_type, :first_name, :last_name, :card_name) end def selected_myaccount_tab(tab) tab == 'credit_cards' end end
view: _form.html.erb<% if @credit_card.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@credit_card.errors.count, "error") %> prohibited this credit_card from being saved:</h2> <ul> <% @credit_card.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> Please implement me!<br/> <div class="field"> <%= f.label :name %> <%= f.text_field :name %> </div> <div class="actions"> <%= f.submit %> </div>
new.html.erb:<div class='nine large-9 columns'> <h3> New Credit Card </h3> <%= form_for(@credit_card, :url => myaccount_credit_cards_path(@credit_card)) do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> <%= link_to 'Back to List', myaccount_credit_cards_path, :class => 'button' %> </div>