routes

How to force Laravel Project to use HTTPS for all routes?

淺唱寂寞╮ 提交于 2019-12-03 04:52:26
问题 I am working on a project that requires a secure connection. I can set the route, uri, asset to use 'https' via: Route::get('order/details/{id}', ['uses' => 'OrderController@details', 'as' => 'order.details', 'https']); url($language.'/index', [], true) asset('css/bootstrap.min.css', true) But setting the parameters all the time seems tiring. Is there a way to force all routes to generate HTTPS links? 回答1: You can set 'url' => 'https://youDomain.com' in config/app.php or you could use a

Laravel 5 how to validate route parameters?

邮差的信 提交于 2019-12-03 04:49:53
问题 I want to validate the route parameters in the "form request" but don't know how to do it. Below is the code sample, I am trying with: Route // controller Server Route::group(['prefix' => 'server'], function(){ Route::get('checkToken/{token}',['as'=>'checkKey','uses'=> 'ServerController@checkToken']); }); Controller namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Http\Requests; class ServerController extends Controller { public

Creating SEO friendly URLs in Rails 3

三世轮回 提交于 2019-12-03 04:44:32
I currently have URLs which look like this: things?category_id=6&country_id=17 and I would like to have URLs which look like this: /printer_cartridges/united_kingdom Is there a way in Rails 3, without hard coding all of the categories and countries in the router to have the URLs as I would like above, perhaps using find_by_name or the such like? What is the best way to approach this? match '/:category_slug/:country_slug', :to => 'things#index' Then you'll need to update your action to look up everything using params[:category_slug] and params[:country_slug] instead of the ids. Look at the

Backbone.js route optional parameter

╄→尐↘猪︶ㄣ 提交于 2019-12-03 04:43:30
问题 Is it possible to have optional parameters in a Backbone.js route? e.g this: routes: "search/[:query]": "searchIndex" instead of: routes: "search/": "searchIndex" "search/:query": "searchIndex" 回答1: As of Backbone 0.9.9, you can add optional paramaters with parentheses. For example in your routes object you can define an optional route part like this: routes: { "organize(/:action)": "displayOrganize" } Now the url path will match /#organize and routes like /#organize/create . Keep in mind

How to reset scroll position on a route change?

感情迁移 提交于 2019-12-03 04:40:26
I spend my first couple of hours with Angular JS and I am trying to write a SPA with it. However, on changing route, the scroll position remains at its current position after changing routes. This means that if someone read through half of the text on page two, this person will end up in the middle of page when two after changing to the second page. (Given that the pages are equally long.) When I look for solutions I only find people asking for the opposite, i.e. they do not want to change the scrolling position once they change pages. However, I failed to reproduce even that. I wonder if the

Routing in Backbone.js / Marionette.js - no hashtags, route list and sub-routers

五迷三道 提交于 2019-12-03 03:50:30
I have three questions about routing in Backbone.js / Marionette.js : 1) How can I get a list of all the routes my application's routers have registered ? For example for Express.js (in Node.js) it would be app.routes . I'm trying to do the same with Backbone.js / Marionette.js but couldn't find any property or method that did this. 2) I want to clean-up my URLs and remove the hashtag "#" in front of them, I know that they trigger the Routers so how can I manage to do this ? I found the following script that prototypes the Backbone router, but it's more of a hack than a stable solution :

Rails routing: Giving default values for path helpers

℡╲_俬逩灬. 提交于 2019-12-03 03:46:22
Is there some way to provide a default value to the url/path helpers? I have an optional scope wrapping around all of my routes: #config/routes.rb Foo::Application.routes.draw do scope "(:current_brand)", :constraints => { :current_brand => /(foo)|(bar)/ } do # ... all other routes go here end end I want users to be able to access the site using these URLs: /foo/some-place /bar/some-place /some-place For convenience, I'm setting up a @current_brand in my ApplicationController : # app/controllers/application_controller.rb class ApplicationController < ActionController::Base before_filter :set

Create named routes for OmniAuth in Rails 3

北慕城南 提交于 2019-12-03 03:39:51
After having watched Ryan's excellent Railcast Simple OmniAuth , I've managed to implement authentication in my app. Everything is working fine, but in my view I have links that look like this: <%= link_to 'Sign in with Twitter', '/signin/twitter' %> <%= link_to 'Sign in with Facebook', '/signin/facebook' %> I was wondering if there is an elegant way to create a named route to replace that with: <%= link_to 'Sign in with Twitter', signin_twitter_path %> <%= link_to 'Sign in with Facebook', signin_facebook_path %> or: <%= link_to 'Sign in with Twitter', signin_path(:twitter) %> <%= link_to

rails 3 - one app, multiple domains, how implement a different 'root' route for one of the domains?

断了今生、忘了曾经 提交于 2019-12-03 03:19:08
Several different domains names point to my app on heroku, for example foo.com and bar.com both point to the app. (We host specialized blog pages, and foo.com is the domain used by our Users who are creating web pages, and bar.com is the 'public facing' domain where the blog pages are.) All the user-editing pages have Devise authentication, and the "root" on foo.com is the User's dashboard page. And a logged-in user can preview their blog page at foo.com/reviewpage/USERID each User acount also has a unique "friendly url name" such as "acme-inc-dallas-tx" On the public-facing web page bar.com

RESTfully Nesting Resource Routes with Single Identifiers

那年仲夏 提交于 2019-12-03 03:16:05
In my Rails app I have a fairly standard has_many relationship between two entities. A Foo has zero or more Bars ; a Bar belongs to exactly one Foo . Both Foo and Bar are identified by a single integer ID value. These values are unique across all of their respective instances. Bar is existence dependent on Foo: it makes no sense to have a Bar without a Foo. There's two ways to RESTfully references instances of these classes. Given a Foo.id of "100" and a Bar.id of "200": Reference each Foo and Bar through their own "top-level" URL routes, like so: /foo/100 /bar/200 Reference Bar as a nested