routes

event.preventDefault() not working for routeChangeStart in angularjs app

浪子不回头ぞ 提交于 2019-12-29 05:13:09
问题 Hope any angularjs gurus can help me with this.Here is my angularjs code $scope.$on('$routeChangeStart', function(event, next, current) { if ($scope.myForm.$dirty) { if(!confirm("Unsaved, do u want to continue?")) { event.preventDefault(); } } }); It alerts in browser back button click when data is dirty, but on clicking cancel or ok it still completes the route change.Seems like event.preventDefault() is not working. Can any one point out what may be wrong 回答1: I had lots of trouble finding

Devise routing: is there a way to remove a route from Rails.application.routes?

落爺英雄遲暮 提交于 2019-12-29 03:36:12
问题 devise_for creates routes including a DELETE route, which we want to remove, and devise_for doesn't support an :except or :only option. How can I remove a route from Rails.application.routes ? Either in the draw block, or afterward? Here are details of a bug, which was the reason we needed to remove the route. we were issuing a DELETE request to a custom UJS controller action in the controller action we were removing what we wanted to, then doing a 302 redirect. This was a bad idea, and we

Rails query string with a period (or full stop).

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 01:37:19
问题 I am currently trying to get a handle on RoR. I am passing in two strings into my controller. One is a random hex string and the other is an email. The project is for a simple email verification on a database. The problem I am having is when I enter something like below to test my page: http://signup.testsite.local/confirm/da2fdbb49cf32c6848b0aba0f80fb78c/bob.villa@gmailcom All I am getting in my params hash of :email is 'bob' . I left the . between gmail and com out because that would cause

Dynamically modify RouteValueDictionary

泪湿孤枕 提交于 2019-12-28 18:29:09
问题 As a followup of this question, I'm trying to implement a custom route constraint in order to dynamically modify the RouteValueDictionary for a specific route. I'm 95% of the way there: I can match any route based on the supplied parameter pattern matching the action specified in the url. The very last step of this process is to overwrite the RouteValueDictionary to rename the keys as the appropriate parameters for the controller action. Here's the relevant snippet of my code (the entire

Placing js files in the views folder

坚强是说给别人听的谎言 提交于 2019-12-28 16:52:10
问题 I am trying to place my javascript files with my views. I have the following js file location. /Views/Home/Home.js However, when referenced with a script tag, it results in a 404 error. As per the following SO question: ASP.NET MVC - Where do you put your .js files if you dont want to store them in /Scripts? I added file.js to my Register routes. (Did not resolve the problem) public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{file}.js"); routes.IgnoreRoute("

Setting up Rails routes based on QueryString

时光毁灭记忆、已成空白 提交于 2019-12-28 05:33:08
问题 I've seen similar questions on this, but not quite what I'm looking for... Forgetting for a moment the wisdom of doing this, is it possible to do this?... /object/update/123?o=section # ==> route to SectionController#update /object/update/456?o=question # ==> route to QuestionController#update ...and if so, how would that be done? 回答1: Assuming you're using Rails 3+, you can use an "Advanced Constraint" (read more about them at http://guides.rubyonrails.org/routing.html#advanced-constraints).

Routes in Codeigniter - Automatically

做~自己de王妃 提交于 2019-12-28 04:25:06
问题 I have a problem with Codeigniter routes. I would like to all registered users on my site gets its own "directory", for example: www.example.com/username1 , www.example.com/username2 . This "directory" should map to the controller "polica", method "ogled", parameter "username1". If I do like this, then each controller is mapped to this route: "polica/ogled/parameter". It's not OK: $route["(:any)"] = "polica/ogled/$1"; This works, but I have always manually entered info in routes.php : $route[

Rails routing to handle multiple domains on single application

不羁的心 提交于 2019-12-27 12:10:45
问题 I've been unable to find a workable solution to this problem, despite several similar questions here and elsewhere. It seems likely that this question hasn't been answered for Rails 3, so here goes: I have an application that currently allows users to create their own subdomain that contains their instance of the application. While in Rails 2 you were best served using the subdomain-fu gem, in version 3 it's dramatically simpler, as per the Railscast -- http://railscasts.com/episodes/221

I am trying to redirect to the show action(so I can see the new post) if a save is successful in the create action, but getting error?

十年热恋 提交于 2019-12-25 17:43:37
问题 I am trying to redirect to the show action after a successful create action in order to see the post the user just made (Post controller). I am getting this error message: syntax error, unexpected keyword_ensure, expecting end-of-input More debugging info: unless source.valid_encoding? raise WrongEncodingError.new(@source, Encoding.default_internal) end begin mod.module_eval(source, identifier, 0) ObjectSpace.define_finalizer(self, Finalizer[method_name, mod]) rescue => e # errors from

Routes on comments and votes

℡╲_俬逩灬. 提交于 2019-12-25 16:55:47
问题 I have two models that can be commented on, Books and Movies. The comments are votable In my routes file: resources :books, :path => '' do resources :comments do member do post :vote_up end end In my comments controller: class CommentsController < ApplicationController def create book.comments.create(new_comment_params) do |comment| comment.user = current_user end redirect_to book_path(book) end private def new_comment_params params.require(:comment).permit(:body) end def book @book = Book