title: POST method/Create action works for some methods but not others, Feedzirra
body: <p>Ok I am making a JQuery .post request to a server to insert some data. It only works sometimes depending on what methods are in the Rails create method.</p>
  
  <p>Here are the specifics. I have a Rails app with Backbone.js on the frontend. In my frontend code I make this .post request</p>
  
  <pre><code>$.post('/publications');
  </code></pre>
  
  <p>Seems simple enough. I have a Publication model as well as</p>
  
  <pre><code>resources :publications
  </code></pre>
  
  <p>in the router. Now in my Publications controller I augmented the create method to the following:</p>
  
  <pre><code>  def create
      feed = Feedzirra::Feed.fetch_and_parse(publication_params[:url])
      params = {:name =&gt; feed.title}
      @publication = Publication.new(params)
  
      respond_to do |format|
        if @publication.save
          format.html { redirect_to @publication, notice: 'Publication was successfully created.' }
          format.json { render action: 'show', status: :created, location: @publication }
        else
          format.html { render action: 'new' }
          format.json { render json: @publication.errors, status: :unprocessable_entity }
        end
      end
    end
  </code></pre>
  
  <p>Feedzirra is a gem that parses RSS feeds. When I make the POST request like this I get a 500 (Internal Server Error) and this message from my server logs</p>
  
  <pre><code>NoMethodError (undefined method `title' for {}:Hash):
    app/controllers/publications_controller.rb:28:in `create'
  
  
    Rendered /Users/ericabt1/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (40.3ms)
    Rendered /Users/ericabt1/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
    Rendered /Users/ericabt1/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
    Rendered /Users/ericabt1/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (54.7ms)
  </code></pre>
  
  <p>What is confusing me is that if I choose a different method than 'title' like 'entries' or 'nil?' the POST request works just fine. I know that 'title' is indeed a method because when I go into Rails console and create a test Feedzirra object and look at the various methods available I see that 'title' is one of them.</p>
  
  <p>Why does my POST request work for some of these method but not others?!?!?!?!</p>
  
  <p><em><strong></em>*  UPDATE <em>*</em>***</strong></p>
  
  <p>After taking krabbi and Alexander Zolotko's advice I started playing with what FeedZirra is returning. It looks like the line</p>
  
  <pre><code>feed = Feedzirra::Feed.fetch_and_parse(publication_params[:url])
  </code></pre>
  
  <p>is returning an empty hash.</p>
  
  <p>Now when I run the same line in the rails console and hardcode a url in there it returns the proper hash and I am able to grab the title and other values. So it looks like the issue lies with </p>
  
  <pre><code>publication_params[:url]
  </code></pre>
  
  <p>Still working on this and open to suggestions:)</p>
  
  <p><strong>* UPDATE PART TWO *</strong></p>
  
  <p>I thought the problem was that there was no url column in the Publication Model. So I made the proper migration. So here is the schema:</p>
  
  <pre><code>  create_table "publications", force: true do |t|
      t.string   "name"
      t.datetime "created_at"
      t.datetime "updated_at"
      t.string   "url"
    end
  </code></pre>
  
  <p>Back to the controller I have at the bottom: </p>
  
  <pre><code> private
      # Use callbacks to share common setup or constraints between actions.
      def set_publication
        @publication = Publication.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def publication_params
         params.permit(:name, :url)
      end
  </code></pre>
  
  <p>publication_params[:url] is still returning nil. I have also tried the line:</p>
  
  <pre><code>params.require(:publication).permit(:url, :name)
  </code></pre>
  
  <p>which just gives me 400 Bad request error</p>