Socket
Book a DemoInstallSign in
Socket

resources_id_replace

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resources_id_replace

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

resources_id_replace

Replace param name of resources' id. Useful for making user friendly URL.

Example

You can use :replace_id_with option for resources.

resources :users, :replace_id_with => 'name'
    users GET    /users(.:format)            users#index
          POST   /users(.:format)            users#create
 new_user GET    /users/new(.:format)        users#new
edit_user GET    /users/:name/edit(.:format) users#edit
     user GET    /users/:name(.:format)      users#show
          PUT    /users/:name(.:format)      users#update
          DELETE /users/:name(.:format)      users#destroy

Good with the following codes.

class User < ActiveRecord::Base
  def to_param
    name
  end
end
class UsersController < ApplicationController
  def show
    @user = User.find_by_name!(params[:name])
  end
end

Installation

Add this line to your application's Gemfile:

gem 'resources_id_replace'

And then execute:

$ bundle

Or install it yourself as:

$ gem install resources_id_replace

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 29 Nov 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.