jipiboily / monologue

Monologue is a basic blogging engine. It is a Rails mountable engine you can mount in your already existing Rails app, or a in a new one! Enjoy.
http://jipiboily.com/2013/monologue-0-3-0-released-and-monologue-markdown
MIT License
479 stars 196 forks source link

undefined local variable or method when trying to render a page in monologue's application.html.erb. #185

Closed harrisrobin closed 10 years ago

harrisrobin commented 10 years ago

Hello!

so I have created views/layouts/monologue/application.html.erb and i was able to override things, until i attempted to add my nav bar by saying <%= render "shared/nav" %>

I get the following error :

undefined local variable or methodcv_path' for #<#:0x007f9787b88528>`

I don't know how to fix it, I just want the navbar from my main website to appear on my monologue blog so that it matches :)

Thanks, Harris

jipiboily commented 10 years ago

It looks like a problem in your code at first, not in Monologue. There is no such variables or method in all Monologue's code. Can you past the full stack trace in a gist please and give us the link to it?

My guess: your navbar is trying to call cv_path, but from Monologue's context maybe?

harrisrobin commented 10 years ago

Full trace : https://gist.github.com/HarrisRobin/8736791

It works perfectly fine when i render shared/nav in application.html.erb that is located in views/layouts.application.html.erb. What you are saying sounds right (from my limited and rookie perspective) but how do i fix it ?

P.S: I'm loving monologue, thanks for making it so easy to integrate!

Routes :

HarrisrobinCo::Application.routes.draw do

get "pages/cv" resources :contacts, only: [:new, :create] root to: 'pages#about' get '/projects' => 'pages#projects' get '/about' => 'pages#about' get '/cv' => 'pages#cv'

`# This line mounts Monologue's routes at the root of your application.

This means, any requests to URLs such as /my-post, will go to Monologue::PostsController.

If you would like to change where this engine is mounted, simply change the :at option to something different.

#

We ask that you don't use the :as option here, as Monologue relies on it being the default of "monologue"

mount Monologue::Engine, at: '/blog' # or whatever path, be it "/blog" or "/monologue"`

end

jipiboily commented 10 years ago

It looks like it is missing at least one or a couple lines at the beginning?

Is your application open source so I could look at the code? Else, can you create a demo app reproducing that?

jipiboily commented 10 years ago

It looks like the problem is on line 7 of app/views/shared/_nav.html.erb...what is that line? What is that file? Your navbar I guess? hehe

harrisrobin commented 10 years ago

https://github.com/HarrisRobin/harrisrobin.co

I have commited the latest changes, it is open source.

To answer your question, the whole page is my navbar that is why im jsut rendering it. Line 7 is the following :

<li><i class="icon-attach"></i><%= link_to 'curriculum vitae', cv_path %> </li>
jipiboily commented 10 years ago

Try changing cv_path for main_app.cv_path? It looks like it is a route, but from the main app, and it does not exists as a Monologue path...

harrisrobin commented 10 years ago

That fixed it! However, it is not taking the styling it had. Should I copy it's styling to monologue's directory ? (ill just do that if nothing works). Is there a "recommended" way of doing this ?

Thanks for your help, at least it's there now :)

Edit: nevermind, it worked flawlessly.

Thanks again! :D

jipiboily commented 10 years ago

:+1: