friendly-id

FriendlyID Korean slugs

可紊 提交于 2019-12-18 12:37:46
问题 When I add article in Korean language with title e.g.: 신품 FriendlyID gem creates blank slug and url is like /8 ... so this is ID. Look at this link: http://www.srecipe.kr.com/articles/8 Other languages work. How can I get url which is mapped to latin letters like /this-is-url from 신품 ? 回答1: Like all of these permalink solutions, friendly ID uses the parameterize method to convert a string into a URL safe string. like so: require 'active_support/all' puts "Oh Hai There".parameterize => oh-hai

Friendly Id Custom Slug

有些话、适合烂在心里 提交于 2019-12-12 11:22:47
问题 I have a Post model #post.rb extend FriendlyId friendly_id :slug_candidates, use: [:slugged, :history] I'm trying to customize the url for each post like so #post.rb def slug_candidates "#tutorial-#{user.display_name}-#{title}" end Friendly id keeps generating UUID slugs while I'd like it to generate a comprehensive url Typically I get \tutorial-john-49c9938b-ece5-4175-a4a4-0bb2b0f26a27 Instead of \tutorial-john-some-comprehensive-title Thank you 回答1: I edited the response, sorry. It seems

Change the unique generated title names of friendly-id

 ̄綄美尐妖づ 提交于 2019-12-12 08:08:45
问题 I am using the friendly_id gem. In the portfolio.rb I placed these two lines: extend FriendlyId friendly_id :title, use: :slugged As you can see I am also using the slug option. When I create a project with title "example" it works find and I can find the project under mysite.com/projects/example . Now, if I create a second one with the same title I get a title for it like this one: mysite.com/projects/example-74b6c506-5c61-41a3-8b77-a261e3fab5d3 . I don't really like this title. I was hoping

FriendlyID doesn't build HTML escaped slugs

非 Y 不嫁゛ 提交于 2019-12-12 03:49:12
问题 I have friendly_id setup properly and everything works, using slugs. The issue I am having is that some of the names on my Tag model (which is the model that FriendlyId is attached to) need to be HTML escaped. Names like c++ or .net . When I ran Tag.find_each(:&save) , it generated all the slugs for me....but on those tags with those names, this is what happened: > c = Tag.where(:name => "c++") Tag Load (0.9ms) SELECT "tags".* FROM "tags" WHERE "tags"."name" = 'c++' => [#<Tag id: 2, name: "c+

Friendly_Id slugs with ids or dates separated by slashes

走远了吗. 提交于 2019-12-11 22:47:08
问题 I'm using the Friendly_Id 5 gem in my Rails 4 app to make the URL's "friendlier." I can currently generate URLs like /article/my-article-title. On many blog's today, you also see the date or the id in the path. How would I generate URLs like: /articles/23/my-article-title where 23 is the article id. It seems like the slug would actually have to be 23/my-article-title since slugs have to be unique in the DB. Or how would I generate a date based slug like? /articles/2014/01/22/my-article-title

Rails FriendlyId with URLs within URL

旧街凉风 提交于 2019-12-11 19:36:45
问题 My app caches web pages On pages#new, when you submit a URL (without the http:// prefix) a page is created and you're redirected to the show, something like pages/4 where 4 is the ID I'm trying to add friendly_id but am running into issues after adding extend FriendlyId and friendly_id :url to my Page model If I supply "yahoo.com", the redirect goes to page/yahoo.com. yahoo.com is interpreted as {"id"=>"yahoo", "format"=>"com"} and rails tells me Couldn't find Page with id=yahoo If I supply

Why can't I edit and destroy my pins anymore when using friendly_id?

一个人想着一个人 提交于 2019-12-11 11:32:28
问题 I believe I followed all the steps correctly from the friendly_id github page. And I know it works because it changed my url from /1 to /sample-url. However, the problem is I can't edit and destroy anymore the pins in which the url I have changed. I hope someone can help me fix this one. Thank you! /pins_controller.rb class PinsController < ApplicationController before_action :set_pin, only: [:show, :edit, :update, :destroy] before_action :correct_user, only: [:edit, :update, :destroy] before

rails3, clean url, friendly_id, sessions

痴心易碎 提交于 2019-12-11 10:32:15
问题 I'm using friendly_id it works wonderful I add a new private action to my events controller to make sure only events owner can update their events...my show and delete action works fine but when I do an update I get an error ActiveRecord::RecordNotFound in EventsController#edit Couldn't find User with ID=snow-board any suggestions to fix this ? ## Events controller ..scaffold generated code private def correct_user @user = User.find(params[:id]) redirect_to(:controller =>'events', :action =>

slug candidates rails 4

早过忘川 提交于 2019-12-11 10:12:31
问题 I have Job model and Location model in my rails application. I am using postgresql as a database.so i have location_ids as an array field in my Job model for holding locations. I am using FeriendlyId in my application to make my url friendly. when i go to my job show page i am getting this friendly url http://localhost:3000/jobs/seo-trainee but now i also want to include the locations the job has in my url , something like this http://localhost:3000/jobs/seo-trainee-mumbai-tokyo i know we can

Couldn't find [MODEL] without an Id : Rails 4 custom controller action

落爺英雄遲暮 提交于 2019-12-11 03:23:59
问题 I'm trying to create a JSON feed for certain data to pull into a graph I have in a partial. I keep running into "Couldn't find Dam without an Id", and none of the answers on SO seem to have the fix. My params seem to be passing through fine, and I'm a bit perplexed. routes.rb require "resque/server" Rails.application.routes.draw do mount Resque::Server, :at => "/resque" root 'home#index' get 'about', to: 'home#about' resources :dams, only: [:index, :show] do get 'count_data', to: 'dams#count