Multiple optional route parameters in Express?

The expressjs’s guide to routing mentions: Express uses path-to-regexp for matching the route paths; see the path-to-regexp documentation for all the possibilities in defining route paths. Express Route Tester is a handy tool for testing basic Express routes, although it does not support pattern matching. Basically, you can use the ? character to make the … Read more

My Routes are Returning a 404, How can I Fix Them?

On my Ubuntu LAMP installation, I solved this problem with the following 2 changes. Enable mod_rewrite on the apache server: sudo a2enmod rewrite. Edit /etc/apache2/apache2.conf, changing the “AllowOverride” directive for the /var/www directory (which is my main document root): AllowOverride All Then restart the Apache server: service apache2 restart

Routes with Dash `-` Instead of Underscore `_` in Ruby on Rails

With Rails 3 and later you can do like this: resources :user_bundles, :path => ‘/user-bundles’ Another option is to modify Rails, via an initializer. I don’t recommend this though, since it may break in future versions (edit: doesn’t work in Rails 5). Using :path as shown above is better. # Using private APIs is not … Read more

Rails routing to handle multiple domains on single application

It’s actually simpler in Rails 3, as per http://guides.rubyonrails.org/routing.html#advanced-constraints: 1) define a custom constraint class in lib/domain_constraint.rb: class DomainConstraint def initialize(domain) @domains = [domain].flatten end def matches?(request) @domains.include? request.domain end end 2) use the class in your routes with the new block syntax constraints DomainConstraint.new(‘mydomain.com’) do root :to => ‘mydomain#index’ end root :to => ‘main#index’ … Read more

AngularJS – How can I do a redirect with a full page load?

For <a> tags: You need to stick target=”_self” on your <a> tag There are three cases where AngularJS will perform a full page reload: Links that contain target element Example: <a href=”https://stackoverflow.com/ext/link?a=b” target=”_self”>link</a> Absolute links that go to a different domain Example: <a href=”http://angularjs.org/”>link</a> Links starting with “https://stackoverflow.com/” that lead to a different base path … Read more

Web API Routing – api/{controller}/{action}/{id} “dysfunctions” api/{controller}/{id}

The route engine uses the same sequence as you add rules into it. Once it gets the first matched rule, it will stop checking other rules and take this to search for controller and action. So, you should: Put your specific rules ahead of your general rules(like default), which means use RouteTable.Routes.MapHttpRoute to map “WithActionApi” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)