<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Getting Started with RESTful Rails]]></title>
		<link>http://railsforum.com/viewtopic.php?id=1068</link>
		<description><![CDATA[The most recent posts in Getting Started with RESTful Rails.]]></description>
		<lastBuildDate>Tue, 29 Dec 2009 00:20:29 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=115432#p115432</link>
			<description><![CDATA[<div class="quotebox"><cite>agm_ultimatex wrote:</cite><blockquote><p>Was running through this tutorial, and ran into a few problems. I got an error message when trying to use script/generate scaffold_resource. That it could not find that generate script. I also had several errors on the page after I tried to make a new album via http://localhost:3000/albums/new.</p></blockquote></div><p>I also met this problem with this tutorial, should be update to latest ..</p><p>for the rails 2.3.5( which I am using) , it changed back to ./script/general scaffold , not scaffold_resource any more.</p><p>and for the nested path, it should be like edit_artist_album_path(params[:artist_id], album), not edit_album_path(params[:artist_id], album).</p>]]></description>
			<author><![CDATA[dummy@example.com (skargor)]]></author>
			<pubDate>Tue, 29 Dec 2009 00:20:29 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=115432#p115432</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=89131#p89131</link>
			<description><![CDATA[<p>Was running through this tutorial, and ran into a few problems. I got an error message when trying to use script/generate scaffold_resource. That it could not find that generate script. I also had several errors on the page after I tried to make a new album via http://localhost:3000/albums/new.</p>]]></description>
			<author><![CDATA[dummy@example.com (agm_ultimatex)]]></author>
			<pubDate>Fri, 27 Feb 2009 22:04:52 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=89131#p89131</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=13572#p13572</link>
			<description><![CDATA[<p>woud it be better to do the artist finding stuff this way ?:</p><p><pre name="code" class="ruby:nogutter">def find_artist<br />&nbsp; @artist = Artist.find(params[:artist_id)<br />end</pre><br />then in the view you can do @artist.id instead of all the params stuff all the time.</p><p>and you can do the find_artist in a before_filter!</p><p>would you put find_artist in the album controller ?</p>]]></description>
			<author><![CDATA[dummy@example.com (pleatherrebel)]]></author>
			<pubDate>Thu, 15 Feb 2007 20:46:00 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=13572#p13572</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=12955#p12955</link>
			<description><![CDATA[<p>I know why it fails, but I don&#039;t know the proper way to fix it<br /><pre name="code" class="ruby:nogutter">&nbsp; def test_should_get_index<br />&nbsp; &nbsp; get :index<br />&nbsp; &nbsp; assert_response :success<br />&nbsp; &nbsp; assert assigns(:albums)<br />&nbsp; end</pre><br />theres no /albums route any more. it needs to be /artists/1/albums</p><p>hey, how would i get my /albums route back if i wanted a list of all the albums?</p><p>ah, then i&#039;d have to fix the view to not ask for the artist... can of worms</p>]]></description>
			<author><![CDATA[dummy@example.com (pleatherrebel)]]></author>
			<pubDate>Fri, 09 Feb 2007 20:28:50 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=12955#p12955</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=12739#p12739</link>
			<description><![CDATA[<p>How do you fix the functional test for the Albums after this? I&#039;m not sure what causes those tests to get errors. Maybe the nested routes? </p><p>test_should_get_index(AlbumControllerTest):<br />ActionController::RoutingError: No route matches {:action=&gt;&quot;index&quot;, :controller=&gt;&quot;albums&quot;}</p>]]></description>
			<author><![CDATA[dummy@example.com (pleatherrebel)]]></author>
			<pubDate>Wed, 07 Feb 2007 21:59:08 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=12739#p12739</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=10279#p10279</link>
			<description><![CDATA[<p>Thanks for following up on these ryan! I&#039;ve been out of the country for a while and just got back. I&#039;m hoping to dig back into this in the next few days.</p>]]></description>
			<author><![CDATA[dummy@example.com (bp)]]></author>
			<pubDate>Wed, 17 Jan 2007 17:44:23 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=10279#p10279</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9669#p9669</link>
			<description><![CDATA[<div class="quotebox"><cite>goodieboy wrote:</cite><blockquote><p>OK thanks getting somewhere now... but strangely (I&#039;m VERY new to rails and ruby) I can&#039;t seem to set an instance variable in the create action, and view it in the new action template. . If I set the instance variable in the new action, the template gets it. How can I set the error for a login (session resource) in the create action, render the new action, and then have the new action template display the error message? The session is not an activerecord model. (but a resource).</p></blockquote></div><p>Hmm, I&#039;m not sure what the problem is, the template should have access to any instance variables defined in the action. For example:</p><p><pre name="code" class="ruby:nogutter"># controller<br />def new<br />&nbsp; @foo = &#039;bar&#039;<br />end</p><p>def create<br />&nbsp; @foo = &#039;blah&#039;<br />&nbsp; render :action =&gt; &#039;new&#039;<br />end</p><p># in new.rhtml<br />&lt;%= @foo %&gt;</pre><br />This should return &#039;bar&#039; or &#039;blah&#039; depending upon what action ran.</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Wed, 10 Jan 2007 22:06:38 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9669#p9669</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9661#p9661</link>
			<description><![CDATA[<p>OK thanks getting somewhere now... but strangely (I&#039;m VERY new to rails and ruby) I can&#039;t seem to set an instance variable in the create action, and view it in the new action template. . If I set the instance variable in the new action, the template gets it. How can I set the error for a login (session resource) in the create action, render the new action, and then have the new action template display the error message? The session is not an activerecord model. (but a resource).</p><p>- matt</p>]]></description>
			<author><![CDATA[dummy@example.com (goodieboy)]]></author>
			<pubDate>Wed, 10 Jan 2007 21:49:48 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9661#p9661</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9654#p9654</link>
			<description><![CDATA[<div class="quotebox"><cite>goodieboy wrote:</cite><blockquote><p>Another questions here... I&#039;ve noticed that when you go to a resource/new location... and then post with errors, the errors are missing... because the for actually does a redirect to &quot;create&quot;. How do we handle errors from here??&nbsp; Not sessions? <img src="http://railsforum.com/img/smilies/sad.png" width="15" height="15" alt="sad" /></p></blockquote></div><p>It is common to just render the &quot;new&quot; template instead of redirecting, this way the instance variable containing the validation errors is not lost. You could also use sessions, but this is easier.</p><p><pre name="code" class="ruby:nogutter">def create<br />&nbsp; @album = Album.new(params[:album])<br />&nbsp; if @album.save<br />&nbsp; &nbsp; flash[:notice] = &quot;Successfully saved album!&quot;<br />&nbsp; &nbsp; redirect_to :action =&gt; &#039;index&#039;<br />&nbsp; else<br />&nbsp; &nbsp; render :action =&gt; &#039;new&#039; # render here, not redirect<br />&nbsp; end<br />end</pre><br />Also, you can display the errors in the form view like this:</p><p><pre name="code" class="ruby:nogutter"># new.rhtml<br />&lt;%= error_messages_for :album %&gt;</pre><br /></p><div class="quotebox"><cite>goodieboy wrote:</cite><blockquote><p>I&#039;ve assigned &quot;/login&quot; to the restful_authentication plug-in &#039;sessions/new&#039; url. But when there is an error, it brings me back to &#039;/sessions&#039; url (it&#039;s using redirect_back_or_default).</p></blockquote></div><p>Try placing it <strong>above</strong> the other map.connect/map.resource definitions in the routes.rb file. When building the URL, the first possible route that passes the conditions is used.</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Wed, 10 Jan 2007 21:29:28 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9654#p9654</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9650#p9650</link>
			<description><![CDATA[<p>Another question!</p><p>If you create a named resource route... and you want to redirect to the named route instead of the action name... how is that done?</p><p>I&#039;ve assigned &quot;/login&quot; to the restful_authentication plug-in &#039;sessions/new&#039; url. But when there is an error, it brings me back to &#039;/sessions&#039; url (it&#039;s using redirect_back_or_default). </p><p>I just don&#039;t want to hard code: &quot;redirect_back_or_default &#039;/login&#039;&quot; into my controller, when that &quot;/Login&quot; reference is being created in routes.rb. Do you know what I mean? Or is that just the way it has to work?</p><p>- matt</p>]]></description>
			<author><![CDATA[dummy@example.com (goodieboy)]]></author>
			<pubDate>Wed, 10 Jan 2007 20:46:51 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9650#p9650</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9649#p9649</link>
			<description><![CDATA[<p>OK thanks for that. I get it, it&#039;s different than what I&#039;m used to but I&#039;ll give it a try.</p><p>Another questions here... I&#039;ve noticed that when you go to a resource/new location... and then post with errors, the errors are missing... because the for actually does a redirect to &quot;create&quot;. How do we handle errors from here??&nbsp; Not sessions? <img src="http://railsforum.com/img/smilies/sad.png" width="15" height="15" alt="sad" /></p><p>Thanks again!</p><p>- matt</p><p>p.s. I just bought the peep code video and it&#039;s really great!.</p>]]></description>
			<author><![CDATA[dummy@example.com (goodieboy)]]></author>
			<pubDate>Wed, 10 Jan 2007 20:40:09 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9649#p9649</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9624#p9624</link>
			<description><![CDATA[<p>Hope you don&#039;t mind if I answer this one bp.</p><div class="quotebox"><cite>goodieboy wrote:</cite><blockquote><p>What is the best way to create a &quot;Administrative&quot; area for your site?? I can&#039;t figure this one out. Does it mean I have to put code in every controller just to get an admin layout and views? How do you specify that in the url; the &quot;admin/&quot; part?</p></blockquote></div><p>Good question. Normally in a RESTful design, there is no special administration section. Instead, user authentication is added and used to determine if a given user is an admin. If he is, he receives special privileges (access to certain actions). You can use simple <strong>if</strong> conditions in the view to show certain links for the admins. You can then use a before_filter to determine the user going to the given action has the proper access.</p><p>For example, if you create an Albums controller and you only want users to access the list/show actions, you can add a before_filter to the create/update/destroy actions to make sure the logged in user is an administrator. If you want a special layout for the admins, you can do this too by passing a symbol to the <a href="http://api.rubyonrails.com/classes/ActionController/Layout/ClassMethods.html#M000103">layout</a> method so it calls another method to determine the layout (see the example in the link).</p><br /><div class="quotebox"><cite>goodieboy wrote:</cite><blockquote><p>What&#039;s the point of having a url like /products/32/orders/122? Isn&#039;t that a little confusing and this be better: /orders/122? Nested resources don&#039;t make sense to me. I can understand using the list view, to show only the related children, but to create, edit or delete seems strange.</p></blockquote></div><p>Another good question. The only benefit I see is the &quot;/products/32/orders&quot; url where this will show all orders for the given product. Once you get to specifying two ids it gets a little ridiculous IMO. I&#039;m honestly not a fan of nested resources and prefer to just stick with the simple URLs, but other people like them and that&#039;s fine with me. <img src="http://railsforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Wed, 10 Jan 2007 17:51:02 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9624#p9624</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9608#p9608</link>
			<description><![CDATA[<p>Thanks for the tutorial. I&#039;m still really scratching my head on a few things though...</p><p>What is the best way to create a &quot;Administrative&quot; area for your site?? I can&#039;t figure this one out. Does it mean I have to put code in every controller just to get an admin layout and views? How do you specify that in the url; the &quot;admin/&quot; part?</p><p>What&#039;s the point of having a url like /products/32/orders/122? Isn&#039;t that a little confusing and this be better: /orders/122? Nested resources don&#039;t make sense to me. I can understand using the list view, to show only the related children, but to create, edit or delete seems strange.</p>]]></description>
			<author><![CDATA[dummy@example.com (goodieboy)]]></author>
			<pubDate>Wed, 10 Jan 2007 15:57:41 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9608#p9608</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9540#p9540</link>
			<description><![CDATA[<p># In albums_controller.rb</p><p>@albums = Album.find(:all)<br />&nbsp; &nbsp; Replaced with:<br />@albums = Artist.find(params[:artist_id]).albums</p><p>When add New Album or Edit existing Album show Error on URL putting :id instead of :artist_id.<br />Generate Error<br /> ActiveRecord::RecordNotFound in AlbumsController#index<br />Couldn&#039;t find Artist with ID=9<br />The URL Looks Like:<br /><a href="http://192.168.1.36:3000/artists/9/albums">http://192.168.1.36:3000/artists/9/albums</a><br />Instead of:<br /><a href="http://192.168.1.36:3000/artists/4/albums">http://192.168.1.36:3000/artists/4/albums</a> [ To show the List of Albums] or<br /><a href="http://192.168.1.36:3000/artists/4/albums/9">http://192.168.1.36:3000/artists/4/albums/9</a> [ To display the currently added/edited album ]</p><p>On Click Show session dump:<br />--- <br />flash: !map:ActionController::Flash::FlashHash <br />&nbsp; :notice: Album was successfully created.</p><p>I can tell the new Album or the Edit Album successfully update the DB. <br />This makes me wonder where after the flash[:notice] my application is being redirected to the wrong URL ???</p><p>I wonder if @album = Album.new(params[:id]) need to be changed to something else !!!</p>]]></description>
			<author><![CDATA[dummy@example.com (dinooz)]]></author>
			<pubDate>Tue, 09 Jan 2007 18:02:50 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9540#p9540</guid>
		</item>
		<item>
			<title><![CDATA[Re: Getting Started with RESTful Rails]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=9333#p9333</link>
			<description><![CDATA[<p>&lt;b&gt; &quot;Jackpot! We get a listing of albums for artist 1. Too bad the links on this page are now broken. We need to make changes to edit.rhtml, new.rhtml, and show.rhtml just like we did for index.rhtml and include the artist_id in the convenience methods.&quot; &lt;b&gt; &lt;br&gt;</p><p>I should said great Post, really enjoy it and follow up to understand better Restful Applications with Ruby, however this last step still makes me have a hard time, try to edit edit.rhtml, new.rhtml and show.rhtml but seems to mix the artist_id with the regular id.</p><p>Once I create a new album the insert put the record into the DB but the show seems to have confusion in the URL put the :id of the Album instead of the :artist_id</p><p>Best Regards Dino.</p>]]></description>
			<author><![CDATA[dummy@example.com (dinooz)]]></author>
			<pubDate>Fri, 05 Jan 2007 19:40:17 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=9333#p9333</guid>
		</item>
	</channel>
</rss>
