Rails App inside a Rails app's sub-folder - ruby-on-rails

I have a rails app, but a client wants to have another rails app be hosted in a ssub-folder of the first rails app.
I can't find any help on how to do this or if it's possible, because if I go to:
http://example.com/second_app, the first app will try and route it despite another app being situated in the second_app folder.
I hope this makes sense, and someone will be able to help.

Sorry, two Rails apps with one inside the other is not possible.
If all you want is a special page for the client, you need a view, controller, and route:
$ rails g controller Pages second_page
And then change your route (config/routes.rb) from get 'pages/second_page’ to get '/second_page’.
After starting up your rails s, you can then go to localhost:3000/second_page and see your page.
If I’m completely misunderstanding what you’re trying to do, please describe your situation a bit more and I’d be happy to help.

Related

Blogit is not routing in rails 4

Hi guys,
I have just installed blogit into my Rails 4 application. When I go to /blog I get routing error of every single route I have got. I get "undefined local variable or method". It is like that it won't load my routes at all.
Not sure if it make sense though. Please let me know what you want me to put here so you guys can have a look.
I have current_user defined in ApplicationController.
In the installation what I didn't understand is "declare which of your models acts as blogger in your app". That might be the issue.
Thanks in advance.
In case someone is looking for this.
Answer trail is in here. It is Explained fully
So just to sum it up, I added main_app to all of the links in the view and all are good.
Basically when you are in the /blog you will be in the engine, and you need to tell the app the correct path. Thanks to emaxon.

Created an entry in rails console, but app has no idea it exists

I entered
SiteData.create(site_name: "My Site", url: "http://mysite.com")
in the console, SiteData being one of my models. Now I can write SiteData.find(1) and it will echo back the entry. Great!
I'm using the db table to store all the info about my site, such as the name, the url, the Facebook page, the Google Plus pages, etc. SO I need to access it on every page. Okay, I'll use before_filter in the application controller to make this work, right?
So I went into my app, and in the Application controller, I wrote
before_filter :add_site_data
def add_site_data
#site_data = SiteData.find(1)
end
And I get an error: "Couldn't find SiteData with id=1"
What now????
This might not be the best way to do this. I am brand new to rails. But I'm totally stuck and have no idea what's going on or why here. I installed Postgres locally today and set up the test and dev dbs, but it seems to be working fine since I can still create/read/update/destroy entries from the console.
Please help! I'm going nuts here. I am using Rails 4.0.
Resetting the server fixed it.
If you know you're making entries in your database that aren't reflected when you run your app, reset the server.

Ruby on rails app debug and develop

I have been in Ruby on Rails for a while. Now I clone a very nice project from GitHub and i want to debug it with RubyMines.
Can someone please sugest me how do i proceed further? Do I start with Controllers? or Models? or Route.rb file?
I want to understand the app thoroughly and develop the next version with new GUI.
Thanks.
Set your breakpoints wherever you want, in your models, controllers, or views. Then just run the debugger and go to the app in your browser. Whenever the application hits the part of the code where you set your breakpoint, it will stop and then you can go back to RubyMine and debug accordingly. It's really a fantastic feature.
Let me know if you if you're having any trouble with it.
When I am getting familiar with a rails project, I will typically set breakpoints at the controllers and step through the code as requests get to the controllers.

Rails generate scaffold creates blank controller

The last couple of times that I've used 'rails generate scaffold [ModelName]' everything has been generated except that the controller is blank. It contains no methods at all. It's easy enough to copy that in from other sources, but I'm wondering what is going on.
The only unique thing about this application for me is that it's using the ActiveAdmin gem.
Any suggestions for how I could get this working as expected again?
+1 to hajpoj, but there are a couple additional steps you could use to troubleshoot.
What does rails generate scaffold_controller give you? My first suggestion to be to isolate the controller generator and go from there.
Following that, I would actually look in the Rails generator code at the point of controller generation and work backwards from there. Here is (I believe) the entry point, from there, you can follow the code to where things are failing. This is, obviously, not the easiest path, but would probably teach you a lot about the rails internals.

Heroku app url made out of random words

I'm new to rails and heroku, and this may very well seem like a daft question, if so I appologise, but would appreciate someone at least telling me so.
I've followed the heroku "getting started" guide, and managed to deploy a copy of the rails default project. But the url preovided by heroku was http://radiant-ice-84.heroku.com, my question is this:
Does heroku assign a randomly generated url, or have I done something wrong because I don't recognise radiant-ice-84?
Before you closing this question, I would like to say that you in fact could specify the first when you create the app (no need to change again in the setting page) by using:
heroku create your-app-name
If you don't specify a name, Heroku generates one for you. You can change it in your app settings (as you noticed), although a lot of people just buy a domain name and map it to the Heroku-generated name.

Resources