Localized routes with attribute routing in MVC5 - localization

Is it possible to have localized routes with attibute routing feature in MVC5?

Absolutely.
Just add the part of the localized url to the attribute routing

Related

How can an engine provide routes to the main app without using the engine's name?

Devise allows an app to use routes methods like new_user_session_path
But if I create my own mountable engine that does authentication, I have to use myengine.new_user_session_path when calling it in the main app.
How can I use routes urls like Devise does?
Could it be due to using a normal rails engine vs a mountable one?
I think there is now out of the box way to do so. Devise uses special stuff for that. The 'devise_for' method generates all needed routes. Path helpers for that routes (such as 'new_user_session_path') a defined in Devise::Controllers::UrlHelpers and included to ActionController::Base.

Rails 4 Route "match" changes the CSS/JS base URL on template

I'm making a blog system for my Rails application and I'm stuck with this problem a while and don't know what's going on with my routes.
I installed a template for my app and all the css/js/images files from this template are in "public/" not in the assets folder. It was the only way I found to make the template working.
My blog system have this routes:
When I access "/blog" it serves the index view and it loads all the assets from "assets" and "public". But when I try to access "/blog/" or the matched route "/blog/category_slug/post_slug" rails tries to load the files from "public/" with this URL:
"base_url/blog/category_slug" and that's really weird!
I'm current using Rails 4.0.2. Any thoughts?
Fixed the problem adding a "/" before the path to the assets:
From: "css/bootstrap.css"
To: "/css/bootstrap.css"
I still don't know why this only happens in the blog controller, but that worked.
Thanks.

URL to Active Admin edit pages

I'm developing a rails application that administers some data with Active Admin. One of my views exports a PDF that summarizes data in the back-end. I'd like to link each entry in the PDF to the "edit" view in Active Admin associated with that resource.
My question is how to get the URL to a specific Active Admin edit page for a model instance. I can't seem to find the URLs using rake routes or using other methods I found in the documentation.
For all the projects I've used activeadmin on, the edit routes have always been edit_admin_model, with a path that looks like /admin/model/:id/edit. Given this, I would expect your app to have an edit_admin_model_url(model_id) for each model you have an ActiveAdmin file for, that you could use in a link helper when compiling your PDF.
If that doesn't help, could you post the output to rake routes for us?

rails how to generate a http link connect to some path without knowing current domain at backend

For example, I dont know my website name yet, it can be www.abc.com or www.xyz.com
And I want to send a email to my users with the link
www.abc.com/controller1/id/path
or
www.xyz.com/controller1/id/path
How I setup this on rails ???
It doesn't really matter what the hostname of your app is when using the right helper, rails will generate either relative paths or absolute paths for links at runtime (depending on the helper used). url_for is one such helper, link_to is another. Any route that is defined in routes.rb, you get a helper for it. Try looking at the output from rake routes, you'll see which url helpers may already be defined. Just add _path to the routes you see listed in the first column to get a relative path url. For more info on routing see the Rails Guide.

Rails create admin controller and view in other directory and with own style

I need to do own administration logic, with it's controllers, view etc... ActiveAdmin and so over are not good for me. But how can i do this in other directory (for example controllers/admin/). How to write then rails g command? (view must be in folder admin too). Also how to connect twitter bootstrap only for admin controllers?
Have a look at this link, where they use the same admin subdirectory grouping (link broken) example. The example is for an older version of Rails, but should be relatively valid for Rails 3.2.
Edit: See this namespaces question.
rails generate controller admin/Users
For bootstrap, just don't use the bootstrap specific id/class attributes in your admin stylesheet.

Resources