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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:04:33+00:00 2026-06-01T02:04:33+00:00

This is my first time creating a custom action so I’m a bit lost.

  • 0

This is my first time creating a custom action so I’m a bit lost. I created a form where I enter a URL. This URL is passed to my controller where I use the URL to parse html (via Nokogiri).

The problem I am having is that I have no idea how to use this URL parameter that is being passed.

Here is the action in my controller:

def newdeal

 url = @traveldeal.url   #this is where I want to use the URL from my form_for
 doc = Nokogiri::HTML(open(url))


 title = doc.at_css("#content//h2/a").text
 price = doc.at_css(".integer").text[/[0-9\.]+/]
 link = doc.at_css("#content//h2/a")[:href]
 desc = doc.at_css(".descriptor").text

 Traveldeal.create(:title => title, :price => price, :url => link, :description => desc)

 flash[:success] = "Deal successfully added!"
 redirect_to root_path
 end

The error I’m getting is undefined method 'url'. I’ve tried doing something like url = :url and even url = "#{:url}", but I get nil class error, so it appears that I’m just referencing it incorrectly.

The parameter is passed correctly though when I press submit:

{"utf8"=>"✓", "authenticity_token"=>"tGPYiuVO3dtRaNVvd6HAshqpTV7yXCmM1j0dXRSfpR4=", "traveldeal"=>{"url"=>"http://www.sampleurl.com"}, "button"=>""}

Here is the view:

<%= form_for @traveldeal, :url => newdeal_path, :method => 'post'  do |f| %>


<div class="field">
  <%= f.label :url %>
  <%= f.text_field :url, :class => "round"  %>
</div>

<div class="action">
  <%= button_tag "",  :class => "acctSubmit" %>
</div>
<% end %>

Thanks.

  • 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-06-01T02:04:34+00:00Added an answer on June 1, 2026 at 2:04 am

    You need @traveldeal = Traveldeal.new(params[:traveldeal]) before url = @traveldeal.url in your action.

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

Sidebar

Related Questions

This is the first time I'm creating an open-source project, and I've decided (based
I'm creating an asp.net MVC app, first time I've done this. I have a
I am creating a .NET website, and this is my first time using a
This is my first time creating php/mysql code from scratch and Im a little
This is my first time creating a has_and_belongs_to_many association and it is being less
This is my first time creating a SVN repository. I am running into problems
first time creating something like this. How would I create a hotbar type rectangle
This is my first time creating a C# program so I apologize if this
This is the first time I am creating a silverlight animation. I have been
This is my first time making a custom rails generator and I want to

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.