Re: [Rails] Turning URL varables into URLs

2018-01-24 Thread kopf1988
I don't know why you're still trying /cheapevents when you haven't defined 
it at all.

Not best practices really, but try something like:

get 'events/:cost', to: 'upcoming_events#index'

and then in your controller, respond based on things like:

if params[:cost] == "cheap"
  @events = Events.where("price < 5")
end

So you can then navigate to url.name/events/cheap


On Sunday, October 15, 2017 at 12:50:08 PM UTC-5, Ben Edwards wrote:
>
> PS I also tried 
>
> get 'upcoming_events/cost', to: 'upcoming_events#index'
>
>
> On Sunday, October 15, 2017 at 6:49:10 PM UTC+1, Ben Edwards wrote:
>>
>> Great, thanks, almost there.  Mine is slightly different as its not based 
>> on CRUD, its a ruby view based on a SQL view.  So 
>>
>> get '/patients/:id', to: 'patients#show'
>>  
>>
>> Is not quite what I need.  If I have this view as root view (
>> http://domain.tld) and want to pass cost as a variable (
>> http://domain.tld?cost=cheapevents = http://domain.tld/cheapevents). Its 
>> the site root
>>
>> currently I have 
>>
>> root 'upcoming_events#index'
>>
>> *get* 'upcoming_events/index'
>>
>>
>> I tried
>>
>> *get* 'upcoming_events/index:cost', to: 'upcoming_events#index'
>>
>>
>> And it works for root but if I try *http://domain.tld/cheapevents 
>> * I get 
>>
>> No route matches [GET] "/cheapevents"
>>
>>
>>
>>
>>
>>

-- 
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/f6ded599-ba62-492c-bacf-cd2118064cd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Turning URL varables into URLs

2017-10-31 Thread Mugurel Chirica
You can try something like this if the requirements match:

  match "/*path", to: redirect { |params, request|
>
> # Add your logic here or delegate the work to a specific class
>
>
>> # Proof of concept
>
> slug = 'jazz' # You get the slug from the params
>
> price_category = true # You deduce if the slug matches any of your tags
>
>

> if price_category
>
>   "/#{slug}?price=cheap"
>
> else
>
>   slug
>
> end
>
>
>>   }, via: :all
>
>
>

-- 
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/CAL37D8F36mDnbzEHfW4P4_9aLaKP12PJLJRkC3nNn__t%3DHu8XA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Turning URL varables into URLs

2017-10-16 Thread Aboobacker M K
You can use something like this

get 'venue/:name:', to: 'venues#show'

class VenueController
  def show
# render the view by checking params[:name]
  end
end

Check the above linked routing guide for more details

On Mon, Oct 16, 2017 at 12:58 AM, Hassan Schroeder <
hassan.schroe...@gmail.com> wrote:

> On Sun, Oct 15, 2017 at 10:49 AM, Ben Edwards  wrote:
> > Great, thanks, almost there.  Mine is slightly different as its not
> based on
> > CRUD, its a ruby view based on a SQL view.
>
> Irrelevant. You can use any parameter and controller method names
> you choose.
>
> --
> Hassan Schroeder  hassan.schroe...@gmail.com
> twitter: @hassan
> Consulting Availability : Silicon Valley or remote
>
> --
> 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/CACmC4yCwEmH12Lc0yJqhuUR75P3ch
> QMUMR%3DXRDb01Wmf_0h_8Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards
Aboobacker MK

-- 
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/CAP3AYfaTspBec2F%3DatuXkVTit7zx3%3Dx0%2B1jc0sFm8ALRBrtTKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Turning URL varables into URLs

2017-10-15 Thread Hassan Schroeder
On Sun, Oct 15, 2017 at 10:49 AM, Ben Edwards  wrote:
> Great, thanks, almost there.  Mine is slightly different as its not based on
> CRUD, its a ruby view based on a SQL view.

Irrelevant. You can use any parameter and controller method names
you choose.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

-- 
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/CACmC4yCwEmH12Lc0yJqhuUR75P3chQMUMR%3DXRDb01Wmf_0h_8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Turning URL varables into URLs

2017-10-15 Thread Ben Edwards
Aslo *http://localhost:3000/upcoming_events/cost* works but not 
*http://localhost:3000/upcoming_events/cost/cheapevents*.

On Sunday, October 15, 2017 at 6:50:08 PM UTC+1, Ben Edwards wrote:
>
> PS I also tried 
>
> get 'upcoming_events/cost', to: 'upcoming_events#index'
>
>
> On Sunday, October 15, 2017 at 6:49:10 PM UTC+1, Ben Edwards wrote:
>>
>> Great, thanks, almost there.  Mine is slightly different as its not based 
>> on CRUD, its a ruby view based on a SQL view.  So 
>>
>> get '/patients/:id', to: 'patients#show'
>>  
>>
>> Is not quite what I need.  If I have this view as root view (
>> http://domain.tld) and want to pass cost as a variable (
>> http://domain.tld?cost=cheapevents = http://domain.tld/cheapevents). Its 
>> the site root
>>
>> currently I have 
>>
>> root 'upcoming_events#index'
>>
>> *get* 'upcoming_events/index'
>>
>>
>> I tried
>>
>> *get* 'upcoming_events/index:cost', to: 'upcoming_events#index'
>>
>>
>> And it works for root but if I try *http://domain.tld/cheapevents 
>> * I get 
>>
>> No route matches [GET] "/cheapevents"
>>
>>
>>
>>
>>
>>

-- 
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/d07b042a-de66-4ef0-b1c0-419eabe47baa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Turning URL varables into URLs

2017-10-15 Thread Ben Edwards
PS I also tried 

get 'upcoming_events/cost', to: 'upcoming_events#index'


On Sunday, October 15, 2017 at 6:49:10 PM UTC+1, Ben Edwards wrote:
>
> Great, thanks, almost there.  Mine is slightly different as its not based 
> on CRUD, its a ruby view based on a SQL view.  So 
>
> get '/patients/:id', to: 'patients#show'
>  
>
> Is not quite what I need.  If I have this view as root view (
> http://domain.tld) and want to pass cost as a variable (
> http://domain.tld?cost=cheapevents = http://domain.tld/cheapevents). Its 
> the site root
>
> currently I have 
>
> root 'upcoming_events#index'
>
> *get* 'upcoming_events/index'
>
>
> I tried
>
> *get* 'upcoming_events/index:cost', to: 'upcoming_events#index'
>
>
> And it works for root but if I try *http://domain.tld/cheapevents 
> * I get 
>
> No route matches [GET] "/cheapevents"
>
>
>
>
>
>

-- 
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/c732fd97-440f-4e19-922f-4f8182d3d6b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Turning URL varables into URLs

2017-10-15 Thread Ben Edwards
Great, thanks, almost there.  Mine is slightly different as its not based 
on CRUD, its a ruby view based on a SQL view.  So 

get '/patients/:id', to: 'patients#show'
 

Is not quite what I need.  If I have this view as root view 
(http://domain.tld) and want to pass cost as a variable 
(http://domain.tld?cost=cheapevents = http://domain.tld/cheapevents). Its 
the site root

currently I have 

root 'upcoming_events#index'

*get* 'upcoming_events/index'


I tried

*get* 'upcoming_events/index:cost', to: 'upcoming_events#index'


And it works for root but if I try *http://domain.tld/cheapevents* I get 

No route matches [GET] "/cheapevents"





-- 
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/65bc12ae-50da-4fb5-b111-0c19a9a49c30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Turning URL varables into URLs

2017-10-15 Thread Hassan Schroeder
On Sun, Oct 15, 2017 at 6:39 AM, Ben Edwards  wrote:

> I came across something years ago (I think in PHP)  where URLs got unpacked
> into varables in the background.  So
> https://eventpuddle.com/price/cheapevents was mapped in the background and
> created a varable price with a value cheapevents.

At the top of config/routes.rb --

  # For details on the DSL available within this file, see
http://guides.rubyonrails.org/routing.html

HTH,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

-- 
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/CACmC4yA6ZHdB9-P8BKxBsq7hvp7Vqm1V4z_mJ0jN0EH40e2_mw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Turning URL varables into URLs

2017-10-15 Thread Ben Edwards
OK, so I have a homepage and want the user to be able to select a link that 
goes back to it with a varable set.  Example here is the listings site 
lists all events regardless of price and I want users to be able to list 
events under £5.  So I have a link https://eventpuddle.com?price=cheap.  
This is fine but for SEO reasons I want to have the URL something like 
https://eventpuddle.com/cheapevents.  Obviesly I could create another view 
but there are all sorts of things I will ultimatly want ot do this for.  
https://eventpuddle.com/jazz, https://eventpuddle.com/pucn, 
https://eventpuddle.com/art...  i would end up with LOTS of views and have 
to do code changes for eatch (see below).

I came across something years ago (I think in PHP)  where URLs got unpacked 
into varables in the background.  So 
https://eventpuddle.com/*price*/*cheapevents 
*was mapped in the background and created a varable *price *with a value 
*cheapevents*.

This will also be usefull for listing events for a certain venue, whitch I 
have lots.  Dont want to create a view for eatch venue as there are lots 
and I dont want to have to code stuff if I add venues, I simply add a row 
in the database for the new venue.  The kind of URLs I would be looking for 
is https://eventpuddle.com/venue/old-market-assembly or 
https://eventpuddle.com/venue/canteen.

Wondering if there is a way of doing this in rails or another way of 
handeling the same type of thing.


 

-- 
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/797df844-344c-4445-904e-1732687a4199%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.