Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminating default Views #6

Open
danielflueck opened this issue Nov 19, 2012 · 0 comments
Open

Eliminating default Views #6

danielflueck opened this issue Nov 19, 2012 · 0 comments

Comments

@danielflueck
Copy link

Hi
I was playing around with angularjs_scaffold. Great stuff! Thanks. - It took me a long time to figure out the whole process of generating the view. Now I understand it and did some changes in my application, so I can remove all the views from Rails and use just your template views.

At the moment for two models my routes.rb looks like the following:

class JsonRouter
  def self.matches?(request)
    request.format == 'json'
  end
end

Trainingracoon::Application.routes.draw do
   root :to => 'welcome#index'

  constraints JsonRouter do
    resources :trainers
    resources :firms
  end

  get "/*other" => "welcome#index"

end

This routes all the html requests (when initial loading or reloading a page) to welcome#index and uses your layout. All other requests with json are routed correctly. In this case I could remove all the views, which makes the code more readable.

Maybe you like to put this into your library. Thanks anyway.
Daniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant