rake doesn't work when using swagger-docs - ruby-on-rails

I'm using swagger-docs sample to generate my api docs, at the beginning, everything went well. but today when I use "rake swagger:docs" after I change something in controller, nothing happened.
There is no error alert. After I start the server and type url in browser, the UI didn't show what I want.
Is there any special configuration I need to do? or please just tell me how to generate the docs properly.

I had the same problem and I figured it out. But I am using AWS EC2. Just for someone may need it.
RAILS_ENV=production rake swagger:docs

Related

Error Installing importmap on rails application

I am having troubling setting up an existing rails application. I am supposed to set up importmap but it is giving me trouble.
If having trouble viewing the uploaded pic, it says "rails aborted!
Don't know how to build task 'importmap:install'"
Rails error pic
If I run "rails --tasks" importmap:install does show up.
rails --tasks output snippet
As per the attached screenshot of the task list, the actual task name apparently is called app:importmap:install instead of importmap:install.
I'm not sure why that might be the case, though. It seems to me like you might (accidentally?) be working on a Rails engine instead of an actual app?

Ruby scaffolding link not working

So I believe that I have searched on here and not found any question that pertains to my issue so hopefully someone can guide me. I was required (for a course) to create a Ruby scaffolding "products" page. My page links all worked on the local host rails server but when I tried it on Heroku (also required) all the links work EXCEPT the new product page.
I have exhaustively googled but I must admit that all the computer lingo is new to me so I am unsure what any of it means and of what steps are safe. For the reason that if I make things worse, I will never know what to look for to reverse anything. I have included the error that shows up in Heroku. When I searched that I found many different answers causing me to be unsure which is correct.
If anything else is needed just let me know. Many thanks to any and all that reply!
Error on Heroku
The error says, "relation products" does not exist.
Did you make sure to run heroku run rake db:migrate ? After you migrate you'll need to heroku restart
This gets me a lot as part of my Heroku deployments, so I make sure to write a script or rake task which does the git push to deploy to Heroku, then runs these two commands. Then I always use that script to deploy, instead of manually doing a push.

rails issue with scaffold

I'm new to rails and messing around with scaffold. I generated a new one doing rails g scaffold Review artist:string venue:string date:string comments:string then ran rake db:migrate and it looks pretty weird, not how my professor's looked in class. I just opened it in my browser. Anyone able to explain to me why it looks like this? Sorry this is vague but not sure how to search for an answer online. Thanks
edit: I also tried connecting to localhost:3000 after starting my rails server, but it wouldn't load. any suggestions?
It looks like you're trying to access the file directly.
You should rather start your rails server and then access the page via the proper route, eg. http://localhost:3000/reviews

How to get this simple rails project to work on Heroku?

I followed this tutorial to make a simple website where you can enter blog entries. I was able to get it working with a postgresql database on my computer.
Then I pushed it to heroku. It was accepted and everything seemed fine.
When I tried to go to the page in my browser though, it didn't work right. You can see it here.
I even tried setting up a shared postgresql database on Heroku. Am I supposed to make some changes to database.yml to get it to work?
One thing I noticed though is that what I added in the shared postgresql database, the error messages seem to indicate that it does find a database, but doesn't find the table. Am I right? I tried to manually recreate the table using the heroku console, but wasn't able to.
What's going on here? How can I get this to work?
Have you tried heroku run rake db:migrate yet?
If that doesn't fix it what does heroku logs --tail tell you?

Can I somehow execute my db/seeds.rb file from my rails app?

I am building a demo, and I want to make it very easy for a non-technical person to set up and run the demo. I have built a seeds.rb file with lots of demo data in it. I want to be able to reset the rails app to a known state by providing an administrator-level action via a page link. I don't want to provide these non-tech demonstrators with a command line and rake, because they might shoot themselves in the foot.
I have looked into using load 'db/seeds.rb' within a method, but that doesn't quite do what I want. I know I am missing something, but what?
You can call Rails.application.load_seed. That's all rake db:seed does.
I prefer the classic method:
bundle exec rails db:seed
But I guess, that you can also call Rails.application.load_seed as mentioned.

Resources