1

I'm building a simple application where visitors can create/edit a post and get a permalink to their post, but I want the links to be a little longer and harder to guess.

I found "how to make ID a random 8 digit alphanumeric in rails?" that does what I'm trying to do on my site, but it doesn't work on rails 4 as "attr_accessible" is no longer available.

Community
  • 1
  • 1
sebastienb
  • 23
  • 6
  • Sorry, I read your question again and it doesn't looks acceptable. I'm voting to close it. You are receiving this error because Rails 4 does not use attr_accessible. Just remove that line from the model. Yet, your question is invalid. – fotanus Sep 03 '13 at 18:05
  • @fotanus can you say why this is not acceptable? The question seems valid. Has it been asked before and the poster didn't do due diligence to find the answer first? Maybe the question could be rephrased or expanded to ask what to do about the `attr_accessible` error? – stevekohls Sep 03 '13 at 18:12
  • I'm closing for this reason: `Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. [See also: Stack Overflow question checklist](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist)` but I also think this restriction also applies: `There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.` – fotanus Sep 03 '13 at 18:16
  • @fotanus Its clear that i tired what was in the link in my post and I did mention that the error was because attr_accessible is no longer available in rails 4. I couldn't find any examples similar to the one i linked to for rails 4 if i did then i wouldn't have asked the question. If its an invalid question please close or delete. – sebastienb Sep 04 '13 at 00:02

1 Answers1

0

Using SecureRandom? Try this:

SecureRandom.hex[0..7]
fotanus
  • 19,618
  • 13
  • 77
  • 111