Socket
Book a DemoInstallSign in
Socket

check_path

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check_path

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

CheckPath

Build Status Gem Version

CheckPath extends ActionView::Helpers::UrlHelper in Rails application. It just add some methods, such as root_path?, post_path?(id: 1), and so on.

Installation

Add this line to your application's Gemfile:

gem 'check_path'

And then execute:

$ bundle

Usage

When you add to Gemfile and run bundle install, you can use some methods in view files.

If your config/routes.rb is follows:

Rails.application.routes.draw do
  resources :posts, only: [:index, :new, :edit, :show]

  root 'posts#index'
end

Then following methods are available in your view files:

  • root_path?
  • posts_path?
  • new_post_path?
  • edit_post_path?(:id)
  • post_path?(:id)

For example, you can check current page is new_post_path or not in app/views/layouts/application.html.erb:

<% if new_post_path? %>
  <!-- Show only in new_post_path -->
<% end %>

Background

As you know, the logic of these methods are as follows. So you might this gem is not required.

def root_path?
  current_page?(root_path)
end

However, using this gem, your code will more clearly.

Contributing

  • Fork it ( https://github.com/kami30k/check_path/fork )
  • 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 a new Pull Request

FAQs

Package last updated on 21 Jan 2015

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.