Giter VIP home page Giter VIP logo

Comments (10)

bigpresh avatar bigpresh commented on June 15, 2024

Just to check the obvious first, you haven't used e.g. /admin/foo in the prefix option to the simple_crud(...) call, right?

from dancer-plugin-simplecrud.

xvaara avatar xvaara commented on June 15, 2024

Right, no I haven't ;) sorry about leaving that out.

from dancer-plugin-simplecrud.

xvaara avatar xvaara commented on June 15, 2024

The load_app + prefix combo adds the prefix to every post/get/etc inside the loaded file.

from dancer-plugin-simplecrud.

xvaara avatar xvaara commented on June 15, 2024

Actually if I'm reading the Dancer source code correctly the current prefix is added to every get/post/etc, so I don't know why you'd need to include $args{dancer_prefix} in those.

from dancer-plugin-simplecrud.

bigpresh avatar bigpresh commented on June 15, 2024

There's a little confusion between the prefix argument to simple_crud(...) and Dancer prefix settings. The former is just what the URLs to edit stuff in that table will start with; if there's a Dancer prefix in effect, it will be prepended.

So, let's say you're using the example app shipped with the module - it's editing records in the people table, so it uses prefix => '/people'. This means that listing records will be at /people, editing a record will be at /people/edit/:id, etc. However, if there's a Dancer prefix setting in effect, then it will be prepended - so, if say the Dancer prefix is /foo, then listing people will now be at /foo/people.

Does that help clarify things? Is that what's going on?

from dancer-plugin-simplecrud.

xvaara avatar xvaara commented on June 15, 2024

When you register a route (like post, get or any) it (Dancer::Route) add's the dancer prefix to the route, if you add it to your route in your plugin it's added twice. Just removed the $args{dancer_prefix} from the get/post and any in sub simple_crud and my program works again. I really can't see how it has worked for anyone using prefix.

from dancer-plugin-simplecrud.

jjcc avatar jjcc commented on June 15, 2024

Hi bigpresh,
I was about to report the exactly the same issue before happened to find out that xvaara already did here. Not only I tested with an applicaiton, but also I have the same conclusion with xvaara about the reason after having read the code.

There are a couple of options. Right now I get around the problem by using "prefix undef;" instead of "prefix '/admin'", then inside the β€œsimple_crud(”, I use " prefix => '/admin/files'". It works.

I could also modify "_construct_url()" but it is called in quite a few places. I might mess up the code. You understand more about this module.

Thank you guys for this very useful module anyway.

from dancer-plugin-simplecrud.

hwy801207 avatar hwy801207 commented on June 15, 2024

I add
prefix "foo";
to simplecrud-example.pl, It's not work out as desc of documents, "/foo/people" can not list the records from database.
When I change /foo/people to /foo/foo/people i get the records

from dancer-plugin-simplecrud.

joshrabinowitz avatar joshrabinowitz commented on June 15, 2024

@bigpresh is this still an issue?

from dancer-plugin-simplecrud.

bigpresh avatar bigpresh commented on June 15, 2024

Wow, er, this sat for quite some time. Sorry!

Yes, I can confirm the behaviour, and also confirm that removing the use of $args{dancer_prefix} when constructing route paths to pass to get, post etc, and leaving it just to be used to formulate URLs for links in the templates, does indeed solve the problem.

from dancer-plugin-simplecrud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.