ActionCable issues on app upgraded to Rails 5 - ruby-on-rails

ActionCable is not working on my app that I just upgraded to Rails 5.0.1.
I generated a channel with rails g channel.
When I run the server I don't see any line in the log that indicates ActionCable is doing anything. On the client side I get App is not defined
I created a new app with rails new and ActionCable works fine in it. I compared all the relevant files in and they look the same in both apps.
Are there some gems that I need to install in my upgraded app that would be installed by default in a new Rails 5 app? I checked and I have actioncable.

My problem was that cable.js was not included in application.js because I have my javascript files included explicitly by name and forgot to add cable.
Don't know if this Q&A will help anyone else, but if it does....

Related

How to fix the warning: "DEPRECATION: action_cable.js has been renamed to actioncable.js – please update your reference before Rails 8"? (Rails 7.0.4)

I have a Ruby on Rails single page application using React as the front-end, and since we upgraded from Rails 6.1 to Rails 7.0, the warning "DEPRECATION: action_cable.js has been renamed to actioncable.js – please update your reference before Rails 8" appears on the browser console in almost every page of the application, except for static views (without forms or such) such as e-mails and the home page.Warning on the browser console
I've tried reviewing my Gemfile to make sure they are up-to-date, ran bundle update hoping that the problem was caused by an outdated gem, but the warning is still there. I've checked the project folder, and there is no "action_cable.js" or "actioncable.js" file, nor are there any references to those files/paths in any part of the code.
Does anybody have an idea on how to fix this warning? I couldn't find any information on how to do it, or other people that are having the same issue.
This is my first time posting here, so if there's any information missing, I'll be more than happy to share it!

Rails app issue with URL

I deployed today on 2 different AWS environments (set up identically) the same version of our app.
On our second app, I have an issue when users click on a link.
Link should redirect to my_app/module#/page and instead, it redirects to my_app/module#!/#%2Fpage
Locally and on the first app, it works fine. I look and could not find the reason why encoding is changed in this instance.
They are both rails app. nginx used on both servers if that can help
Thanks.
Issue was due to Angular version on one of my apps.
After editing the package.json file and re deployed, everything is back to normal.
issue related: URL hash-bang (#!/) prefix instead of simple hash (#/) in Angular 1.6)

the user cannot destroy a record in a rail 5 application after deployment with Capistrano?

I have developed a very simple apps for trying out deployment on AWS server with Rails 5.0.0.1 and ruby 2.3.1.
As a user, I can delete a record without any problems on my localhost:3000. However I cannot delete a record after I have successfully deployed to a AWS amazon server with Nginx, Puma and Capistrano at 35.161.251.52/contacts, if you want to try. The destroy link becomes a show link.
I have followed this tutorial at https://www.sitepoint.com/deploy-your-rails-app-to-aws/
Can anyone shine a light on this? Thanks a lot!
My guess is that your javascript files have not been successfully deployed thus the handler that would handle the delete method of the link doesn't execute. Thus the link just makes a get request to its href and ends up to the show page.
Open developer tools from your browser and check if your assets are loaded correctly.

How do I do api in Rails 4? Rails-api gem is merged in Rails 5

I already have a Rails 4 website.
Now I'm building a mobile app and need to get data from the the same database my website is using.
It looks like rails-api gem is merged in Rails 5. But Rails 5 is not production-ready yet and is not supported by such gems as devise.
Docs are all on merged version:
http://edgeguides.rubyonrails.org/api_app.html
So which gem and guide should I use to create an api for my website at the moment?
There's nothing in Rails 4 that prevents you from building an API. Why not create an API in your existing Rails app under a namespace? There are some gems like Grape that can help, but they're not necessary. There are many tutorials on the topic including some Rails Casts that are still relevant, so it should be easy.
The Rails API gem is a lighter version of Rails that is stripped down to only the core parts that an API app needs. This means you don't have ActionView or server generated templates. It's basically Rails minus anything that an API doesn't need.
By being merged into Rails 5, it simply means that Rails 5 will give you the option to create a stripped-down app that only has what an API app needs (minus ActionView and other cruft).
But everything inside of Rails API is inside Rails and more.
But since you already have a Rails app running, just build the API into it. If you want to create an API only app, then go ahead and create one using either the Rails API gem, a normal Rails app, or even Sinatra.
You can create an api on your own without any gem doing api. Try to follow some examples like: Building a RESTful API in a Rails Application and others.

rails update question: where are the new files?

Some time ago I updated my app from Rails 1.2 to 2.3. The upgrade definitely worked (was in pagination hell for a while), and the app has been working fine.
But now I'm in the process of upgrading my app for mobile use and want to use the Mobile Fu plugin. However, that calls for changing the mime_types.rb file... and I don't have that. In fact, I don't have the entire Initializers folder in my config folder, nor the locales folder.
How do I get these directories into my app? Are there other things I'm missing? And what did I do wrong in the upgrade process?
Thanks!
Running rake rails:update should have handled all the requirements of a Rails 2.3 app. Initializers are not a requirement -- they are a new convenience that was added. If you want the same default file structure as a new Rails 2.3 app, I recommend creating a dummy app and copying the initializer and environment files over so you're working with up-to-date templates.

Resources