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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:51:40+00:00 2026-06-06T16:51:40+00:00

UPDATE I answered my question below, but I am still asking for a prettier

  • 0

UPDATE

I answered my question below, but I am still asking for a prettier way to achieve my goal. I have a feeling my controller knows too much about how to do things.


I have a create action in my VideoController :

def create
  method = 'get_' + params[:video][:provider] + '_video_id'
  provider_video_id = Video.send(method, params[:video][:url])
  thumb = Video.get_thumb_from_youtube(provider_video_id)

  @video = Video.new(params[:video], :provider_video_id => provider_video_id, :thumb => thumb, :views => 0, :likes => 0)
  if @video.save!
    redirect_to video_path('1'), notice:'Video added successfully.'
  else
    render :new
  end
end

I call Video.new with params[:video] with get its information from a form the user fills in. I then manipulate the URL the user passed in with the form to recover the video_provider_idand thethumb.

However, Rails is not saving the video with provider_video_idand thumb… I get this error on save :

Validation failed: Thumb can't be blank, Thumb is invalid, Provider video can't be blank

My guess is the newmethod doesn’t accept extra parameters…

  • 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-06T16:51:41+00:00Added an answer on June 6, 2026 at 4:51 pm

    I solved the problem. I think Ruby on Rails’ newmethod doesn’t accept more than one parameter, which usually is params. What I did is I the following :

    method = 'get_' + params[:video][:provider] + '_video_id'
    params[:video][:provider_video_id] = Video.send(method, params[:video][:url])
    params[:video][:thumb] = Video.get_thumb_from_youtube(params[:video][:provider_video_id])
    params[:video][:views] = params[:video][:likes] = 0    
    
    @video = Video.new(params[:video])
    

    Now, it seems to work.

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

Sidebar

Related Questions

* UPDATE: *I've already answered my question. But you can still give me advise
UPDATE (spoiler): This question is answered (see David Carlisle answere below) and it looks
This question have been answered. I recommend sumit_programmers solution below. For now, I've removed
Update: this question has been answered (see below). I'll leave it up in case
What the difference between the 2 queries below UPDATE This question is already answered
Update: Is there a way to achieve what I'm trying to do in an
I know there is plenty of question answered over here https://stackoverflow.com/questions/tagged/youtube+regex , but not
(please read the update section below, I leave the original question too for clarity)
UPDATE: Ok, I didn't formulate a good Q to be answered. I still struggle
This question has answered the question for a single column but how do you

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.