Re: [Rails] Re: [QUESTION] How to have different routes ids on different routes for the same resources?

2017-04-21 Thread Maurizio De Santis
>
> resources :posts, param: :slug


FWIK this just changes the name of the parameter passed to the controller,
so if you write post_path(Post.first) you will have a request like
/posts/#{post.to_param} but in the controller instead of have param[:id]
you have param[:slug]

--

Maurizio De Santis

2017-04-20 22:27 GMT+02:00 <batuhanwilh...@gmail.com>:

> You can also do something like this If i get it right,
>
> resources :posts, param: :slug
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/rubyonrails-talk/rneoBmxG4QY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/rubyonrails-talk/ffd0916e-d658-4cb9-b24f-
> c4b3ebb52454%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B_M_Jdcs3E51oQfc%2BAQpBbr%3D3KO9kMZOGn04pu2ATsUQUe_0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: [QUESTION] How to have different routes ids on different routes for the same resources?

2017-04-20 Thread Maurizio De Santis
I have to say that Rails is great. 5.1 introduces a wonderful feature for 
my need: direct 
http://edgeapi.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/CustomUrls.html#method-i-direct

Now in config/routes.rb I can write:

# Content model includes FriendlyId, so content_path(Content.first) calls 
record.to_param using the slug
resources :contents

direct 'edit_admin_content' do |record, options|
  # Here I specify to use the record id, so the resource url will fit 
better with admin section purposes
  options.merge controller: '/admin/contents', action: :edit, id: record.id
end

Same for actions :show, :update and :destroy. Problem solved!

Il giorno giovedì 20 aprile 2017 15:49:55 UTC+2, André Orvalho ha scritto:
>
> I don't think it is an hack what you are doing.
>
> To actually have routes receiving different types of ids you probably 
> needed to change how those helpers are generated by rails.
> That means you might have to monkey patch rails.
>
> The alternative rails is giving you to be able to do this is by doing 
> this: admin_content_path(id: content.id)
>
> So it allows you to pass to override the id passed as argument.
>
> I am sorry but I dont think there is a way around this.
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/2c64950f-5faa-458f-b0f5-2bfdd4017586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] [QUESTION] How to have different routes ids on different routes for the same resources?

2017-03-21 Thread Maurizio De Santis
Hello,

I have never found a good solution for the following problem. I have the 
usual structure:

resources :contents

namespace :admin do
  resources :contents
end

When I call content_path(content) I want the id to be the slug of the 
content, while when I call admin_content_path(content) I want the id to be 
the id of the content. I just want the id not to be related on the model 
(actually the id is the returning value of the to_param method of the 
model), but on the route.

I know I can write admin_content_path(id: content.id) or content_path(id: 
content.slug), but this is just an hack actually. Also, this is especially 
annoying in form_for, since I can't write

form_for @content

but I'm forced to use

form_for @content, url: @content.new_record? ? admin_contents_path : 
admin_contents_path(id: @content.id)


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/b76a4010-1cd8-432c-ac7b-7cf508cb7c33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] [Show RoR] Ruby and Ruby on Rails merged documentations

2014-04-23 Thread Maurizio De Santis
Hello,

I just almost completed this project: 
http://mdesantis.github.io/ruby-rails-documentations/ 

It provides Ruby and Ruby on Rails documentations merged together, like 
railsapi.com used to do (it is online no more).

Feel free to share your opinions about it.

Cheers

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/15ff25e9-9b0f-4928-af66-8b30b5b97ae1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Developing a web chat using Rails 3

2010-09-04 Thread Maurizio De Santis
Hi!

I'm trying to develop a web chat (like the facebook one, but much
simpler) that works inside Rails 3, and so I'm inquiring about the
methods used for this scope. I had some success applying this guide
http://www.web2media.net/laktek/2010/02/16/building-real-time-web-apps-with-rails3/
, so now I am able to send messages form the server to the client.

Anyway, I read about some sort of XML-based protocol called XMPP, which
seems to be widley used in this cases. I really don't know anything
about either cramp or XMPP, and so I would ask:

* Do you have some info about cramp (guides, explanations, examples...)?
apart from the above post, I found this
http://m.onkey.org/2010/1/7/introducing-cramp , and nothing else (maybe
because it is relatively young?) Above all..
* ... how does cramp work? Is a parallel server? A thread? What is it???
:)
* Is XMPP the way? Do you know how to implement it?
* Do you know anything about the argument? Every contribute is
appreciated!
-- 
Posted via http://www.ruby-forum.com/.

-- 
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-t...@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.



[Rails] Re: setting the size of a textarea

2010-08-02 Thread Maurizio De Santis
Tim Shaffer wrote:
 It's possible you have a style that is overwriting the rows and cols
 attribute.
For my experience, it's better to not use rows and cols for dimensioning 
textareas, because the dimensions of the textarea will depend from the 
dimensions of the row and of the column, that rely to font properties 
and change from browser to browser; it would be a good choice to set 
dimensions with css (width and height, to be clear). Consider this:

html
head
/head
body
textarea cols=10 rows=10 style=font-size: 10px/textareabr
textarea cols=10 rows=10 style=font-size: 20px/textareabr
/body
/html

textareas dimensions are very different; this:

html
head
/head
body
textarea cols=10 rows=10 style=font-family: Arial/textareabr
textarea cols=10 rows=10 style=font-family: 
Verdana/textareabr
/body
/html

I obtain 136x208 vs 138x228; on Firefox, 79x164 vs 89x164 on Chromium
-- 
Posted via http://www.ruby-forum.com/.

-- 
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-t...@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.