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 6091635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:21:03+00:00 2026-05-23T12:21:03+00:00

I’m writing an entry submission controller by this tutorial: http://www.communityguides.eu/articles/1 When I try to

  • 0

I’m writing an entry submission controller by this tutorial: http://www.communityguides.eu/articles/1

When I try to submit an entry, I get Users can't be blank…I don’t want to pass the user_id in as a hidden field, right? So how should I change this to automatically get the user’s id?

I’m using devise for authentication. 🙂 And I’m a complete rails novice.
This is my controller:

    def submit
      @entry = current_user.articles.find(params[:id])

      # submit only, if article is currently in draft or rejected-state
      if (@entry.state == 0) or (@article.state == 2)
        @entry.state = 1
        @entry.submitted = Time.now

        if @entry.save
          flash[:notice] = 'Your article was successfully submitted for approval.'
        else
          flash[:error] = 'There was an error while submitting your article.'   
        end           
      else
        flash[:error] = 'This article can not be submitted.'  
      end

      respond_to do |format|
        format.html { redirect_to(:action => 'myarticles') }
        format.xml  { head :ok }
      end
    end
  # GET /entries/1/edit
  def edit
    @entry = Entry.find(params[:id])
  end

  # POST /entries
  # POST /entries.xml
  def create
    @entry = Entry.new(params[:entry])

    respond_to do |format|
      if @entry.save
        format.html { redirect_to(@entry, :notice => 'Entry was successfully created.') }
        format.xml  { render :xml => @entry, :status => :created, :location => @entry }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @entry.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /entries/1
  # PUT /entries/1.xml
  def update
    @entry = current_user.entries.find(params[:id])

        #if the entry has been approved, the user cannot change the title or URL.
        if @entry.state > 2
            params[:entry].delete(:title)
            params[:entry].delete(:url)
        end
    respond_to do |format|
      if @entry.update_attributes(params[:entry])
        format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @entry.errors, :status => :unprocessable_entity }
      end
    end
  end
  • 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-23T12:21:03+00:00Added an answer on May 23, 2026 at 12:21 pm

    From your description it seems that you would encounter this error when trying to create a new Entry.

      def create
        @entry = current_user.entries.new(params[:entry]) # <-- Scope to the current user
    
        respond_to do |format|
          if @entry.save
            format.html { redirect_to(@entry, :notice => 'Entry was successfully created.') }
            format.xml  { render :xml => @entry, :status => :created, :location => @entry }
          else
            format.html { render :action => "new" }
            format.xml  { render :xml => @entry.errors, :status => :unprocessable_entity }
          end
        end    
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I am writing an app with both english and french support. The app requests
I have this code to decode numeric html entities to the UTF8 equivalent character.
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.