-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Route issue. #53
Comments
Hi @houmanka - you have to call the class User < ActiveRecord::Base
blogs
end Thats what we mean by "declare which of your models acts as blogger in your app" |
When you say router, are you referring to routes? If so, I think the following section in the Rails guide should help. http://edgeguides.rubyonrails.org/engines.html#routes Basically, when on a page within the Blogit engine, you need to specify main_app prior to your normal app's path. For example, main_app.root_path. Likewise, outside of the Blogit engine, your paths need to be blogit.blog_path. However, line 82 of the blogit.rb initializer allows you "to call named routes without the main_app prefix." Here's the link to that file within the sample Blogit app. |
Hi @emaxon This is my route file:
If I go to any other page all are fine and there is no rounting or method error. Thanks again for your help. |
Hi @houmanka, The problem exists in your View — specifically your _header.html.erb You need to either prepend all of your paths with main_app.path_name (ie. main_app.user_path) OR uncomment line 82 of the config/initializers/blogit.rb file (remember to restart your Rails server if you do this). Basically, when you are go to your blog, you are within the Blogit engine and must specify that the paths are external to that engine. |
I have added main_app as prefix to all of my links and everything works. Thank you. Now I get a new error: Thanks again for your help mate. |
Can you post your application_controller.rb? My only point of reference on this will be the file provided in the example Blogit repo here: |
hmmm, I have made my own Authentication and using Declarative Authorisation for the Access List. Now when I try to save the post I get User#username is not defined Thanks again guys. |
I think this might be because the show action will, by default, call the display name method. See the config template |
Where should I define that :username method? in the application_controller.rb? Thanks mate |
No - it's a method that's defined on your model. It's used in this partial to show who wrote the post In most cases this would be :username or :full_name but since every app will be different, we give the option to customise which model method is used. |
NICE, |
Hi, I am trying to use blogit in my application. Now clicking on /blog, I am also getting the error - At the beginning of this issue, it is suggested to uncomment line#82 config.inline_main_app_named_routes = true from config/initializers/blogit.rb However, it seems the config option inline_main_app_named_routes is no more valid. Is there any other way to resolve the routing error apart from prefixing all routes with main_app. Thanks in advance, |
Pl. ignore the above comment. I was able to resolve my issue with help from this article - Thanks |
yeah -- same error here . . . maybe this should be in the readme -- i haven't fixed the error yet, but this clearly happens with rails defaults set |
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 router 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".
Where should I declare that? so that might be the issue here.
Thanks in advance.
The text was updated successfully, but these errors were encountered: