codemancers / rapidfire

Making dynamic surveys should be easy!
https://rapidfire.fly.dev/
MIT License
319 stars 141 forks source link

Path issues #146

Open rohangrg opened 4 years ago

rohangrg commented 4 years ago

Hey,

For devise gem, we are using an employee model rather the user model, So when I use your gem, it is causing issues with our routes.

Screenshot 2020-01-08 at 1 43 58 PM

in the application controller, I am using

`def current_user current_employee end

def can_administer? true end`

designium commented 4 years ago

I have similar issue. Rapidfire cannot find any of other controller's routes and it keeps giving error that a route path is an undefined local variable or method not found.

ZacharyWeiner commented 4 years ago

I have a similar issue and it was solved by adding the initializer. But, after adding the initializer, and loading up the rapidfire root, clicking on "New Survey" leads me to a new error.


ActionView::Template::Error (undefined method `surveys_path' for #
<ActionDispatch::Routing::RoutesProxy:0x00007fa78701b1a8>):
    1: <h3><%= survey.new_record? ? "New Survey" : "Edit Survey" %></h3>
    2:
    3: <%= form_for survey do |f| %>
    4:   <%- if survey.errors.any? %>
    5:     <ul>
    6:       <%- survey.errors.full_messages.each do |message| %>

In this error, RapidFire cant find its own surveys path and the problem is surfaced from the Rapid Fire Initializer:

 main_app_route_methods.each do |m|
      define_method m do |*args|
        main_app.public_send(m, *args)
      end
      helper_method m
end

So, I was thinking that it's telling me that Im supposed to use the url_for helper in all the forms... So I went into the views and updated the form to use the url_for

<%= form_for url_for(survey) do |f| %>

which worked to load the new survey page, but then on submission of the survey info I get: No route matches [POST] "/rapidfire/surveys/new"

Which is true. In the rake routes list the :post route for new_survey_path is 'surveys/new' not rapidfire/surveys/new

Any help is appreciated.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs for another 14 days. Thank you for your contributions.

mihaic195 commented 4 years ago

To reference routes inside the rapidfire engine from outside the engine you need to prepend the path with rapidfire. E.g. rapidfire.surveys_path

To reference routes outside the engine, from within the engine, you need to prepend your routes with main_app. E.g. main_app.some_other_path. (Or some other engine)