Some basic questions

  1. I have a text area in which I type on multiple lines…but when I
    display it, it prints whole text in one line…how can I solve that?
    Datatype is TEXT

  2. I can see a list of all posts at …post/ with index method but I want
    to see a particular post with …post/[id] … how can I do that?

  3. I want my application to be completely secured and whatever page
    unlogged in user tries to open, it should redirect to :controller =>
    ‘user’, :action => ‘login’ … some before_filter maybe but I dont know
    where to put that to secure all of the application.

  4. How to display a column of options from a table into a drop down
    list, with id being their value.?

Thanks in advance

  1. HTML ignores whitespace unless it’s inside a

     tag or you
    change the CSS whitespace property. I would recommend formatting the
    text field for display with simple_format(text). Read about it here:
    http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M000623
  2. In your index action in the controller, add @post =
    Post.find(params[:id]) if params[:id] and pass the id of the post you
    want in the params

  3. Use the login_required method in the authenticated_system.rb of
    restful_authentication (or acts_as_authenticated) as a before_ftiler
    or model yours after it. See the restful_authentication documentation.

  4. Sorry, not following you here.

On Sep 3, 1:16 am, Vapor R. [email protected]

unknown wrote:

  1. Sorry, not following you here.

like I have a table called statuses and in there I have some columns
including id and status_name

I want to get all the ids and status_names and display them in drop down
list with status_names being displayed in drop down but when submitted
value being the ids sent to database.

I hope it makes sense

unknown wrote:

  1. Use the login_required method in the authenticated_system.rb of
    restful_authentication (or acts_as_authenticated) as a before_ftiler
    or model yours after it. See the restful_authentication documentation.

that is some kind of plugin…could you please give link to some tutorial
on how to use that because I learned user authentication just a couple
of hours ago

  1. In your index action in the controller, add @post =
    Post.find(params[:id]) if params[:id] and pass the id of the post you
    want in the params

It says

Unknown action
No action responded to 4

:S

I would definitely suggest that you familiarize yourself with the
basic concept of user authentication in rails before you start using a
plugin (so that you understand what the plugin does). The Agile Web
Dev. with Rails book has a user authentication section that goes over
it briefly. The restful_authentication plugin itself has excellent
README and RDoc documentation and the code is quite easy to follow as
well, so you may want to check it out. (the plugin is in
technoweenie’s plugin repository, google should find it for you
easily, and there are various resources online that can help you
integrate it, including a wiki for the original acts_as_authenticated
plugin)

  1. check api.rubyonrails.org for the collection_select form helper.

On Sep 3, 1:42 am, Vapor R. [email protected]

Vapor R. wrote:

:S

Sounds like your routes.rb has been screwed up. post the contents.

/path/to/project/config/routes.rb

It sounds like his get params are fubared. 4 is probably the id he
wants but he’s put it in the action param instead. Of course 4 could
also be the id of nil, but we’ve got whiny nils to prevent that
confusion.

On Sep 3, 1:56 am, Vapor R. [email protected]

Anthony R. wrote:

Sounds like your routes.rb has been screwed up. post the contents.

/path/to/project/config/routes.rb

ActionController::Routing::Routes.draw do |map|
map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’
map.connect ‘:controller/:action/:id.:format’
map.connect ‘:controller/:action/:id’
end

Vapor R. wrote:

ActionController::Routing::Routes.draw do |map|
map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’
map.connect ‘:controller/:action/:id.:format’
map.connect ‘:controller/:action/:id’
end

Looks OK. What URL are you using?

http://///

examples:
http://localhost:3000/post/show/4

if you want to do
http://localhost:3000/post/4

you need to change your routes and controller to suit. I would recommend
looking into usig REST instead of the standard rails generator code.

Anthony R. wrote:

Looks OK. What URL are you using?

http://///

examples:
http://localhost:3000/post/show/4

if you want to do
http://localhost:3000/post/4

you need to change your routes and controller to suit. I would recommend
looking into usig REST instead of the standard rails generator code.

currently I am using http://localhost:3000/post/show/4 but i want to use
http://localhost:3000/post/4

dont know about REST or something…n00b :frowning:

Default rails routing is :controller/:action/:id which means that
http://localhost:3000/post/4 gives the params { :controller =>
‘post’, :action => ‘4’, :id => nil }

You want params like { :controller => ‘post’, :action => ‘index’, :id
=> ‘4’ }

So your link would be http://localhost:3000/post/index/4

Ideally you would be using link_to to create this link.

As an aside, it may make more sense to make this a show action that
also lists the posts rather than an index action that also shows a
post.

On Sep 3, 2:17 am, Vapor R. [email protected]

Anthony R. wrote:

Vapor R. wrote:

currently I am using http://localhost:3000/post/show/4 but i want to use
http://localhost:3000/post/4

dont know about REST or something…n00b :frowning:

I found this PDF
http://www.rubyinside.com/restful-rails-development-pdf-released-392.html
and the 2006 keynote by DHH http://www.scribemedia.org/2006/07/09/dhh/
was all I needed to get started.

thanks Anthony :slight_smile:

Vapor R. wrote:

currently I am using http://localhost:3000/post/show/4 but i want to use
http://localhost:3000/post/4

dont know about REST or something…n00b :frowning:

I found this PDF
http://www.rubyinside.com/restful-rails-development-pdf-released-392.html
and the 2006 keynote by DHH http://www.scribemedia.org/2006/07/09/dhh/
was all I needed to get started.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs