Denis,

I did this sort of thing with user accounts a while ago.. I had set up
a site that needed to mark users as 'inactive' if they ever decided to
close their account.

Your issue with web crawlers seeing the Move to Trash link makes me
think this page is public and not member-only accessible? If so, I
can't think of any way to tell a spider to not look at particular
parts of the text (maybe there is a way, i've always done a
traditional approach and told the spider to leave my whole page
alone). Either way, on to a possible solution:

The two actions I would have are:
(already in your code) desotry - this action houses the traditional
rails destroy method that will remove the record from the table and
any dependencies.
(need to add) move_to_trash - the new action that will call the
move_to_tash method we will create on the object in view

Explanation:
You should not modify the destroy action and following rails
conventions and good programming practice I would not pass a parameter
into a destroy action and then decide what kind of 'destroy' to
execute. Rather, let's create a second action called move_to_trash
with the same access privileges as the destroy. The reason we do this
is because logically our two actions are doing very different things,
one is destroying a sql record and the other is changing an attribute
on an object.

So we add a move_to_trash method to the model and subsequently we will
want a new column on our model moved_to_trash (boolean). Now the
move_to_trash action will call the model.move_to_trash and then that
method will called a self.update_attribute(:moved_to_trash, true).

[[Alternatively, this is where I like to encourage using enums in your
database and have your model have states. It could be very clean to
have a column "status" and then you
have :moved_to_trash, :inbox, :other_cool_states ]]

Hopefully you find this helpful. If you provide more details about
your particular situation we can work out a solution that fits.

On May 22, 1:54 am, Denis Kokin <denis.ko...@gmail.com> wrote:
> Thank you, Frederick.
>
> Can you give me more details? Some sample code would be useful for me.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to