Blogit is not routing in rails 4 - ruby-on-rails

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.

Related

Rails App inside a Rails app's sub-folder

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.

No route matches on Rails

I have installed one of my RoR app on my local computer from GitHub.
And trying to have it running on my local machine
But after successful login they throwing me this error which drives me crazy.
I tried to find out solutions, but failed.
Can u guys please explain me possible reasons for this error?
Thanks.
No Route Matches basically means you're trying to load a URL / Route which doesn't exist in your config/routes.rb file
To fix it, you have to look at the request you've sent to Rails & see if it's matched within the routes file. If not, ActionDispatch::Routing will not be able to direct your request to the correct controller / action
You need to give us the actual error & show the routes.rb file to get an accurate answer

Understanding Application.routes.draw source code

A couple of months ago I started developing web apps with Rails. As with any new framework I use, as a step to further understanding it I’ve started to read the source code. Maybe it’s my relative recent learning of Ruby, but I’m having some troubles making sense of it.
Today I decided to look into Application.routes.draw (from routes.rb) and from the ActionDispatch::Routing documentation I found the draw method defined in rails/actionpack/lib/action_dispatch/routing/route_set.rb but I fail to see where in Application.rb (or Engine.rb or Railtie.rb) it comes into play. Additionally I don’t see where the routes method in Application is defined.
Any answer or link greatly appreciated. Thanks in advance.
Ok, I finally found the routes method in engine.rb, line #488. I’ll take it from there.

Rails 3 Contact form

I recently followed a tutorial on a how to add a contact form in rails 3 for a site I am building. I already had a contact controller and view from when I created that page and was trying to implement the form. I coming to realize maybe the tutorial isn't in rails 3 when it says it is. I keep getting an error( undefined method `deliver_contact' for Notifications:Class. ) that I can't seem to figure out. I tried changing some thing around from the tutorial but nothing is working. Any guidance would help me out? I am thinking about just deleting what I did and starting over fresh with the contact form but wanted to check and see if anybody has an idea. Thanks! The link to the site is below and I followed exactly what was there.
http://metatroid.com/article/How%20To:%20Contact%20Form%20in%20Rails
Use
Notifications.contact(params[:email]).deliver
More info

How can I edit routes.rb in runtime dynamically from rails app?

I have a situation that I needed to edit routes.rb from rails app progammatically. Need an idea how to do it. I am rails beginner.
When you change something in "routes.rb" you must restart app, so It is very bad idea. You can do with one controller/route. This controller can redirect to some other other controller or do something so you can use ONE ROUTE in routes.rb. You can write some your code here and We will help you.

Resources