Comments (4)
Is there any info that needs to be update for clarify?
from lucky.
redirect_back
is working as expected. When you went to the edit page from the universities index page, the index was the referrer. But when you submit the form, the referrer is the get request for the edit page which is why it sent you back to it. I would recommend passing the url you want to send them back to as a field in the form if that's what you really want. Otherwise, just always redirect to the index
(Of course, I could be wrong).
from lucky.
This issue has been going on for some time, please let me try to reexplain it with more details.
- When i visit
GET /universities/788/edit
from the index page ("http://127.0.0.1:3000/universities"),I add some pp! code in the edit page
, as following, the output ofcontext.request.headers["Referer"]
andprevious_url(Universities::Index)
in the form page both correct.
both output in the edit form page
web | context.request.headers["Referer"] # => "http://127.0.0.1:3000/universities"
web | previous_url(Universities::Index) # => "http://127.0.0.1:3000/universities"
- Let me submit the form
Then submit the form use PUT action, as you said in the reply, action print referer as edit page correctly
output in the action
request.headers["Referer"] # => "http://127.0.0.1:3000/universities/788/edit"
- We save the form successfully, the code is jump into the following
redirect_back
as following.
if operation.saved?
pp! "Print in update action", request.headers["Referer"]
flash.success = "修改成功"
> redirect_back fallback: Index, allow_external: true
else
flash.failure = "出错了"
html EditPage, operation: operation, university: updated_university
end
- Then the following output is the pp! in the edit page. (redirect_back redirect page back to original edit page in this case)
web | GET /universities/812/edit
web | ▸ Handled by Universities::Edit
web | "Print in form" # => "Print in form"
web | context.request.headers["Referer"] # => "http://127.0.0.1:3000/universities/812/edit"
web | previous_url(Universities::Index) # => "/universities"
web | ▸ Rendered Universities::EditPage
web | ▸ Sent 200 OK (3.11ms)
- so, the issue is, why
previous_url(Universities::Index)
return "/universities"? as the expected behavior said in your reply ofredirect_back
, previous_url should return edit page, right?
@matthewmcgarvey Thanks.
from lucky.
My guess is maybe a bug in previous_url
?
I'm not sure what this line is doing
lucky/src/lucky/page_helpers/url_helpers.cr
Line 106 in e069903
from lucky.
Related Issues (20)
- Add some sort of `with_keys` option to `send_json` HOT 1
- Add an option to configure size of secret key
- Add the compile time to the watcher in development
- Add format flag to `lucky routes` for outputting alternate formats
- Adding a strip_tags helper with allow list capabilities
- Add native ECR support
- Add distance_of_time_in_words that takes a Time::Span
- Add Date header to responses
- Create handler to mutate param key names
- Action based rate limiting HOT 2
- Improve the error output when newbie user forget settings LUCKY_ENV to production.
- Compile error using Crystal nightly HOT 1
- gen.action.browser doesn't mention the --with-page flag
- Changing the DEV_PORT doesn't update the watcher reload_port shown in terminal HOT 12
- Compile time should reset when recompiling
- Building a route with array params doesn't work HOT 1
- Expected Hash for #[]?(key : String), not Array(JSON::Any)
- File.readable? is deprecated starting Crystal 1.13
- build lucky project use Crystal 1.13.0-dev [4dce0d594]) cause 'strict_transport_security' error when running lucky. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lucky.