Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 822725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:50:24+00:00 2026-05-15T02:50:24+00:00

Sorry for this question but I can’t find my error! In my Project I

  • 0

Sorry for this question but I can’t find my error!
In my Project I have my model called “team”.
A User can create a “team” or a “contest”. The difference between this both is, that contest requires more data than a normal team.
So I created the columns in my team table.
Well… I also created a new view called create_contest.html.erb :

<h1>New team content</h1>

<% form_for @team, :url => { :action => 'create_content' } do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </p>
  <p>
    <%= f.label :url %><br />
    <%= f.text_fiels :url %>
  </p>
  <p>
    <%= f.label :contact_name %><br />
    <%= f.text_fiels :contact_name %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

In my teams_controller, I created following functions:

  def new_contest
  end

  def create_contest
    if @can_create

      @team = Team.new(params[:team])
      @team.user_id = current_user.id
      respond_to do |format|
        if @team.save
          format.html { redirect_to(@team, :notice => 'Contest was successfully created.') }
          format.xml  { render :xml => @team, :status => :created, :location => @team }
        else
          format.html { render :action => "new" }
          format.xml  { render :xml => @team.errors, :status => :unprocessable_entity }
        end
      end
    else
      redirect_back_or_default('/')
    end
  end

Now, I want on my teams/new.html.erb a link to “new_contest.html.erb”.
So I did:

<%= link_to 'click here for new contest!', new_contest_team_path %>

When I go to the /teams/new.html.erb page, I get following error:

undefined local variable or method `new_contest_team_path' for #<ActionView::Base:0x16fc4f7>

So I changed in my routes.rb, map.resources :teams to map.resources :teams, :member=>{:new_contest => :get}

Now I get following error: new_contest_team_url failed to generate from {:controller=>"teams", :action=>"new_contest"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["teams", :id, "new_contest"] - are they all satisfied?

I don’t think adding :member => {...} is the right way doing this. So, can you tell me what to do? I want to have an URL like /teams/new-contest or something.

My next question: what to do (after fixing the first problem), to validate presentence of all fields for new_contest.html.erb? In my normal new.html.erb, a user does not need all the data. But in new_contest.html.erb he does. Is there a way to make a validates_presence_of only for one action (in this case new_contest)?

UPDATE:
Now, I removed my :member part from my routes.rb and wrote:

map.new_contest   '/teams/contest/new', :controller => 'teams', :action => 'new_contest'

Now, clicking on my link, it redirects me to /teams/contest/new – like I wanted – but I get another error called:

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

I think this error is cause of @team at <% form_for @team, :url => { :action => 'create_content_team' } do |f| %>

What to do for solving this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:50:24+00:00Added an answer on May 15, 2026 at 2:50 am

    Okay, I found my errors.
    For the record:
    First of all, I forgot to write the code inside my def new_contest. Here it is:

      def new_contest
        if @can_create
          @team = Team.new
          respond_to do |format|
            format.html # new.html.erb
            format.xml  { render :xml => @team }
          end
        else
          redirect_back_or_default('/')
        end
      end
    

    There were several typos, too, in my .erb file like text_fiels instead of text_field or create_content instead of create_contest.

    current_user is working fine for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this question is very easy, but I can't find the answer anywhere.
Sorry for this newbie question, but I can't find on google what I need
Sorry about the vocabulary question but I can't find this anywhere: how do you
I'm sorry if this question has been asked. I have looked but can not
Sorry if this seems like a stupid question but can't find any info on
Sorry if this question has already been answered but I can't find an answer.
Sorry if this question may be simple, but I can't seem to find an
Sorry if this question is silly, but I can't seem to find the answer
Sorry if this question's been asked before, but I can't seem to find an
fans Sorry for this newbie question, but I can't find on google what I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.