How to create dynamic pages without form_for helper in Rails?

108 views Asked by At

Lets say I have a blog and inside of that blog I have blog posts(ie. all belong to "resources :posts"). The only difference that those blog posts are not going to be generated by users with the use of form_for helper but automatically by rails.

I'll try to make a simple example to make it clear...

Lets say My blog app is able to scrape YouTube and everyday it scrapes it to check what is the most viral video of the day. Then it would go and create a blog post automatically without me or other users actually typing in anything inside of the forms to create a post with that video inside it.

Lets say on the first day my blog app scrapes YouTube and retrieves: 1)url of the video to embed on the page 2)title, for the first ever post. My question is how would I pass this information to posts_controller.rb to create a new post, so that if say I go to myblogapp.com/posts/1 it would show me the first post.

1

There are 1 answers

6
Chris Peters On

Learn how to write a rake task and how to schedule that task to run periodically (daily?) with cron or some other scheduler. No need to build a form.