0

I'm currently developing a Rails Application with a large set of engines.

I have some paths to Engines root-path stored in a database.

However, if I try to link to them using the value from the database (it's stored in the 'root_path'-Field) and the link_to helper in the view I don't get the correct link.

Here's an example (assume that the root_path in the database is currently foo_engine.bar_path)

- @engines.each do |engine|
  = link_to engine.name, engine.root_path

instead of:

http://localhost:3000/foo_engine.bar_path

I get

http://localhost:3000/current_engine/foo_engine.bar_path

Thank you in advance

Philipp

4
  • 1
    can you do rake routes in the terminal and post the result? Commented Aug 30, 2013 at 20:56
  • Thank you! The problem is that I want to route to a different engine and the path to the engine is stored in the database. Commented Aug 30, 2013 at 20:57
  • Glad the problem is fixed! Commented Aug 30, 2013 at 21:01
  • Ah sorry. I just want to say thank you that you tried to help me :-) The problem is still there :-D Commented Aug 30, 2013 at 21:03

1 Answer 1

1

Ok, I've found a solution for this one.

Just use

- @engines.each do |engine|
  = link_to engine.name, eval(engine.root_path)

But eval is evil. Is there another way?

Sign up to request clarification or add additional context in comments.

2 Comments

I think this use of eval is safe. You are not using eval on user submitted content. Have you tried "/#{engine.root_path}"
Thank you for your comment! I just have tried your suggestion. "#/{engine.root_path}". Unfortunately it's not working since the conversion from the helper-Method to the url get's not triggered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.