José Luis Romero wrote: > Done! Same results... > > uninitialized constant MysqlCompat::MysqlRes > > Thanks... Any other approach? Try setting ARCHflags. OSX Snow Leopard will return the same results you're getting if you don't set the ARCHflags. You'll have to look them up for your system, but the syntax is something like this: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config When you get the ARCHflags parameter right, that should resolve your uninitialized constant issue. If you then get the "No definition for [ResourceName]" ri and RDoc warnings/errors, first uninstall your gem again, and then you'll have to do something like this: sudo env ARCHFLAGS="-arch x86_64" gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/mysql/bin/mysql_config http://forums.mysql.com/read.php?116,359591,359591#msg-359591 That may or may not be enough to get the mysql gem working in your environment. I'm still tracing out problems. Regards, mike -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Nikhil Gupte wrote: > Jean, > > Best is to install macports, if you aren't already using it. > > To re-compile ruby, run: > > sudo port install ruby I was able to get mysql gem to install on OSX Leopard without warnings with the --no-rdoc and --no-ri switches; archflags likewise eliminated the uninitialized constant error: sudo gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/local/mysql/bin/mysql_config That hasn't made my installation functional however. I just rebuilt my entire project with rails myApp -d mysql; I then scaffolded 5 sets of tables (i.e. script/generate scaffold tablename c_code:string c_name:string tran_id:integer priority:integer); I next drag the project directory onto XCode Organizer; create the start server script (script/server); and start the gem server in terminal: gem server. Fine and dandy so far (seemingly). Then I run rake db:migrate to engender the following error: iMacMike:pfmpe mikemontagne$ rake db:migrate --trace (in /Users/mikemontagne/rproj/pfmpe) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! Unknown database 'pfmpe_development' ---------- database.yml indicates that this is supposed to be the development database. But no such file exists in my project directory. Is this a MySQL server configuration issue? Does anybody understand why this table is not being created? -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Thanks Conrad, I have removed the save call from the code, but it continues to return an empty JSON on success case. Any more clues? On Mar 21, 3:37 pm, Conrad Taylor <conra...@gmail.com> wrote: > On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch <fabi...@gmail.com> wrote: > > Hi all! > > > I'm playing with Rails 3, and on one of my controllers I have the > > following update method defined: > > > def update > > @category = @user.categories.find(params[:id]) > > @category.update_attributes(params[:ecategory]) > > @category.save > > respond_with @category > > end > > Fabio, you should not be calling save within the update > action because 'update_attributes' calls save implicitly. > Thus, you should do something like the following: > > class CategoriesController < ApplicationController::Base > > respond_to :html, :json > > def update > > @category = @user.categories.find( params[:id] ) > > if @category.update_attributes( params[:category] ) > > flash[:notice] = 'Category was successfully created.' > > end > > respond_with( @category ) > > end > > end > > Good luck, > > -Conrad > > I'm using Jquery to interact with the controllers, and when I do an > > > > > ajax PUT, the update action is correctly executed (the fields are > > updated), but the action returns an empty JSON object, which causes > > the Jquery ajax function to fall into an error. > > > I'm I doing something wrong? > > > Thank you all, > > Fabio. > > > -- > > 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+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscrib e@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
On 21 March 2010 21:29, command0 < justinbrinkerhoff@gmail.com> wrote: > I have: > > map.resources :tickets, :has_many => [:notes, :comments] > > In routes.rb. >> > 5: You can view your ticket at <%= link_to @ticket %>. Okay, So when we get to line 5 of app/views/ticket_mailer/newticket.erb, you're passing the @ticket variable to the link_to helper... so what's the value of @ticket at this stage? Is it actually a "Ticket" object, or is it Nil? -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
LOL yeah, I was so tired when I was working on this earlier this morning, I just totally overlooked that. When I change the assignment, I get the "Need controller and action!" error. In the View, here is the whole verbage it spits out: ActionController::RoutingError in Tickets#create Showing app/views/ticket_mailer/newticket.erb where line #5 raised: Need controller and action! Here are the new params:
---------------------------
[4;35;1mSQL (0.1ms) [0m [0mSET NAMES 'utf8' [0m [4;36;1mSQL (0.1ms) [0m [0;1mSET SQL_AUTO_IS_NULL=0 [0m Processing TicketsController#create (for 127.0.0.1 at 2010-03-21 14:52:09) [POST] Parameters: {"ticket"=>{"platform_id"=>"", "title"=>"Testing the mailer", "app_version"=>"", "app_id"=>"", "category_id"=>"5", "user_id"=>"2", "os_version"=>"", "status_id"=>"1", "desc"=>"Let's see what happens.", "customer_id"=>"1", "notes_attributes"=>{"0"=>{"body"=>"Trying again."}}}, "commit"=>"Create", "action"=>"create", "authenticity_token"=>"s562boG7oXhkhgeurg4C2mKv/vrAgOg5V/zmZjibMZA=", "controller"=>"tickets"} [4;35;1mUser Columns (49.2ms) [0m [0mSHOW FIELDS FROM `users` [0m [4;36;1mUser Load (0.7ms) [0m [0;1mSELECT * FROM `users` WHERE (`users`.`id` = 2) LIMIT 1 [0m [4;35;1mRole Load (0.4ms) [0m [0mSELECT `roles`.* FROM `roles` INNER JOIN `assignments` ON `roles`.id = `assignments`.role_id WHERE ((`assignments`.user_id = 2)) [0m [4;36;1mRole Columns (1.2ms) [0m [0;1mSHOW FIELDS FROM `roles` [0m [4;35;1mTicket Columns (1.8ms) [0m [0mSHOW FIELDS FROM `tickets` [0m [4;36;1mNote Columns (1.6ms) [0m [0;1mSHOW FIELDS FROM `notes` [0m [4;35;1mCustomer Columns (1.6ms) [0m [0mSHOW FIELDS FROM `customers` [0m [4;36;1mCustomer Load (0.8ms) [0m [0;1mSELECT * FROM `customers` WHERE (`customers`.`id` = 1) [0m
ActionView::TemplateError (Need controller and action!) on line #5 of app/views/ticket_mailer/newticket.erb: 2: 3: A new ticket titled "<%= @ticket.title %>" has been created for you on the Student Helpdesk Portal. 4: 5: You can view your ticket at <%= link_to @ticket %>. 6: 7: You may submit comments on the ticket to provide questions or feedback concerning the ticket. 8: app/views/ticket_mailer/newticket.erb:5 app/controllers/tickets_controller.rb:84:in `create' Rendered rescues/_trace (147.5ms) Rendered rescues/_request_and_response (0.5ms) Rendering rescues/layout (internal_server_error) ------------------------------------------------- From the sounds of it, it's a routing issue, which seems a bit odd.... On Mar 21, 2:13 pm, Michael Pavling <pavl...@gmail.com> wrote: > On 21 March 2010 20:03, command0 <justinbrinkerh...@gmail.com> wrote: > > > The problem I am having, is when I try to create a new ticket, I get > > the error: > > > NoMethodError (undefined method `customer' for nil:NilClass): > > app/models/ticket_mailer.rb:7:in `newticket' > > app/controllers/tickets_controller.rb:84:in `create' > > > Which I know simply put is telling me the customer doesn't exist, > > because customer_id would be nil, so there is no association. But > > there is. > > No, it's telling you that the "ticket" variable (at line 7 of > ticket_mailer.rb) is nil, and NilClass objects don't have a "customer" > method. > > > class TicketMailer < ActionMailer::Base > > def newticket(ticket) > > ticket = @ticket > > subject 'A new ticket has been created for you' > > recipients ticket.customer.email > > from 'helpd...@stevenshenager.edu' > > sent_on Time.now > > end > > I'd assume the problem is caused by the assignment in the first line > of the method; I'd guess it's meant to read: > @ticket = ticket > ..because as it is, it doesn't make much sense to pass in a ticket > parameter and then immediately overwrite it with an instance variable. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Maybe I'm stating the obvious, but it seems to suggest that you have simply not backup/copied the public directory, and so your app is picking up public/index.html. If public/index.html exists, just delete it. On Mar 20, 1:33 am, nshenry03 <nshenr...@gmail.com> wrote: > I am simply trying to backup a ruby on rails app... I have created an > archive of the entire database and application folders on server A... > I then restore the database and application folders on server B.... > > Server B is exactly the same as A (same OS, same ruby, gems, etc...) > > However when I go to the site on server B, all I see is: > > Welcome aboard > You're riding Ruby on Rails! > > I've checked and all of the files are in the folders, the DB has data > in it, I've rebooted apache... > > What else do I need to do? -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
On 21 March 2010 20:03, command0 < justinbrinkerhoff@gmail.com> wrote: > The problem I am having, is when I try to create a new ticket, I get > the error: > > NoMethodError (undefined method `customer' for nil:NilClass): > app/models/ticket_mailer.rb:7:in `newticket' > app/controllers/tickets_controller.rb:84:in `create' > > Which I know simply put is telling me the customer doesn't exist, > because customer_id would be nil, so there is no association. But > there is. No, it's telling you that the "ticket" variable (at line 7 of ticket_mailer.rb) is nil, and NilClass objects don't have a "customer" method. > class TicketMailer < ActionMailer::Base > def newticket(ticket) > ticket = @ticket > subject 'A new ticket has been created for you' > recipients ticket.customer.email > from 'helpdesk@stevenshenager.edu' > sent_on Time.now > end I'd assume the problem is caused by the assignment in the first line of the method; I'd guess it's meant to read: @ticket = ticket ..because as it is, it doesn't make much sense to pass in a ticket parameter and then immediately overwrite it with an instance variable. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Hi guys (and gals), I have the most strange issue that I just cannot figure out. It doesn't make sense at all why it's happening, and had a fellow Rails developer friend of mine from the UK look at it with me last night, and still couldn't figure it out. Ok, so I have a helpdesk ticketing system wrote in Rails 2.3.5. The app itself has lots of models and controllers, respectively. The 2 models in the app that I'm working with (well 3 considering the mailer model), is Ticket and Customer. My mailer class is called TicketMailer. To make sense of it for you all, Ticket belongs_to Customer, Customer has_many tickets. That's the relationship between the two. Tickets are created from the customer, so a user has to navigate to the customer in the view and click on the create ticket, which nests the customer_id into the ticket, which is saved to the ticket during the create action. With that said, I created the TicketMailer model, and what I am after, is to deliver an e-mail to the customer when a ticket is created. Here is my TicketMailer model: class TicketMailer < ActionMailer::Base def newticket(ticket) ticket = @ticket subject 'A new ticket has been created for you' recipients ticket.customer.email from 'helpdesk@stevenshenager.edu' sent_on Time.now end
# def ticketstatus(sent_at = Time.now) # subject 'The status of your ticket has changed' # recipients ticket.customer.email # from 'helpdesk@stevenshenager.edu' # sent_on sent_at # end end The other method is commented out for now, as it hasn't been implemented, and so I will fight that battle later...
Here is the view of the e-mail, titled newticket.erb: --------------------------------------------------------------------- Hello <%= ticket.customer.first_name %>, A new ticket titled "<%= ticket.title %>" has been created for you on the Student Helpdesk Portal. You can view your ticket at <%= link_to ticket %>. You may submit comments on the ticket to provide questions or feedback concerning the ticket. As always, feel free to call us anytime at 1-866-888-3768, and we will be happy to help. Thank you for using the Student Helpdesk Portal, and have a great day. Regards, The Helpdesk Team ----------------------------------------------------------------
And here is my create action in my Tickets controller: def create @ticket = Ticket.new(params[:ticket]) @ticket.notes.first.user_id = current_user.id TicketMailer.deliver_newticket(@ticket) logger.debug("@@@ - Customer email is #{@ticket.customer.email}") respond_to do |format| if @ticket.save TicketMailer.create_newticket(@ticket) TicketMailer.deliver_newticket(@ticket) flash[:notice] = 'Ticket was successfully created.' format.html { redirect_to(@ticket) } format.xml { render :xml => @cticket, :status => :created, :location => @ticket } else format.html { render :action => "new" } format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity } end end end For clarification, I placed the deliver above if @ticket.save for now to get it working, since I don't want new tickets getting created before the mailer is working.
The problem I am having, is when I try to create a new ticket, I get the error: NoMethodError (undefined method `customer' for nil:NilClass): app/models/ticket_mailer.rb:7:in `newticket' app/controllers/tickets_controller.rb:84:in `create' Which I know simply put is telling me the customer doesn't exist, because customer_id would be nil, so there is no association. But there is. Here are the params that get passed into the create action. Not the logger.debug message I put which just reiterates that the exact attribute I'm calling is available. Processing TicketsController#create (for 127.0.0.1 at 2010-03-21 00:05:11) [POST] Parameters: {"ticket"=>{"platform_id"=>"", "title"=>"Testing mailer", "app_version"=>"", "app_id"=>"", "category_id"=>"5", "user_id"=>"2", "os_version"=>"", "status_id"=>"1", "desc"=>"Seeing if the mailer works.", "customer_id"=>"1", "notes_attributes"=>{"0"=>{"body"=>"Testing mailer."}}}, "commit"=>"Create", "action"=>"create", "authenticity_token"=>"lFPGXK8LdqYArXPb02lvF9RSywEiK1HehoPQv7etE/c=", "controller"=>"tickets"} [4;36;1mUser Columns (3.4ms) [0m [0;1mSHOW FIELDS FROM `users` [0m [4;35;1mUser Load (0.6ms) [0m [0mSELECT * FROM `users` WHERE (`users`.`id` = 2) LIMIT 1 [0m [4;36;1mRole Load (1.5ms) [0m [0;1mSELECT `roles`.* FROM `roles` INNER JOIN `assignments` ON `roles`.id = `assignments`.role_id WHERE ((`assignments`.user_id = 2)) [0m [4;35;1mRole Columns (5.4ms) [0m [0mSHOW FIELDS FROM `roles` [0m [4;36;1mTicket Columns (2.1ms) [0m [0;1mSHOW FIELDS FROM `tickets` [0m [4;35;1mNote Columns (1.9ms) [0m [0mSHOW FIELDS FROM `notes` [0m [4;36;1mCustomer Columns (1.9ms) [0m [0;1mSHOW FIELDS FROM `customers` [0m [4;35;1mCustomer Load (0.4ms) [0m [0mSELECT * FROM `customers` WHERE (`customers`.`id` = 1) [0m @@@ - Customer email is justin.brinkerhoff@stevenshenager.edu ActionView::TemplateError (undefined method `customer' for nil:NilClass) on line #1 of app/views/ticket_mailer/newticket.erb: 1: Hello <%= @ticket.customer.first_name %>, 2: 3: A new ticket titled "<%= @ticket.title %>" has been created for you on the Student Helpdesk Portal. 4: app/views/ticket_mailer/newticket.erb:1 app/controllers/tickets_controller.rb:85:in `create' Rendered rescues/_trace (141.3ms) Rendered rescues/_request_and_response (0.7ms) Rendering rescues/layout (internal_server_error) [4;36;1mSQL (0.1ms) [0m [0;1mSET NAMES 'utf8' [0m [4;35;1mSQL (0.1ms) [0m [0mSET SQL_AUTO_IS_NULL=0 [0m As you can see, as I put in the create action, @ticket.customer.email displayed the value in the logger.debug message. So, the customer is made available to the new action before hand, so the customer is already there for the create action.
The solution has got to be something silly that I am just not seeing. If someone could help shed some light on this for me, I'd be much appreciative. Thanks, Justin -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
On Mar 21, 7:00 pm, Tiger Big one < li...@ruby-forum.com> wrote: > Hi everyone, i followed colins example and it worked perfectly but now i > get this error > > ActionController::DoubleRenderError in UserController#login > > Render and/or redirect were called multiple times in this action. Please > note that you may only call render OR redirect, and at most once per > action. Also note that neither redirect nor render terminate execution > of the action, so if you want to exit an action after redirecting, you > need to do something like "redirect_to(...) and return". > In the case where the request is a post request and if the user is logged in successfully you are calling redirect_to :action => 'index' twice Fred -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Hi everyone, i followed colins example and it worked perfectly but now i get this error ActionController::DoubleRenderError in UserController#login Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return". I feel that something is wrong with this code def login @title = "Login - Books" if request.post? @user = User.new(params[:user]) user = User.find_by_screen_name_and_password(@user.screen_name, @user.password) if user session[:user_id] = user.id flash[:notice] = "User #{user.screen_name} logged in" redirect_to :action => "index" else # Don't show the password in the view @user.password = nil flash[:notice] = "Invalid email/password combination" end end if session[:user_id] flash[:notice] = "Already registed and logged in! You cannot view the register or login!" redirect_to :action => :index end end /////////////////////////////////////////////////////// if session[:user_id] flash[:notice] = "Already registed and logged in! You cannot view the register or login!" redirect_to :action => :index end /////////////////////////////////////////////////////// what this does, is if session ID is found, then it takes the login page back to index...can someone help me please :( -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
On Sun, Mar 21, 2010 at 9:44 AM, Fabio Kreusch <fabiokr@gmail.com> wrote: Hi all! I'm playing with Rails 3, and on one of my controllers I have the following update method defined: def update @category = @user.categories.find(params[:id]) @category.update_attributes(params[:ecategory]) @category.save respond_with @category end
Fabio, you should not be calling save within the update action because 'update_attributes' calls save implicitly. Thus, you should do something like the following:
class CategoriesController < ApplicationController::Base
respond_to :html, :json
def update @category = @user.categories.find( params[:id] ) if @category.update_attributes( params[:category] ) flash[:notice] = 'Category was successfully created.' end respond_with( @category ) I'm using Jquery to interact with the controllers, and when I do an ajax PUT, the update action is correctly executed (the fields are updated), but the action returns an empty JSON object, which causes the Jquery ajax function to fall into an error. I'm I doing something wrong? Thank you all, Fabio. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
The Sun, 21 Mar 2010 17:12:02 +0100, Heinz Strunk < lists@ruby-forum.com> wrote: > Hello, > > I'm working with probability and Ruby doesn't really does as I want. > Just to make it easier to understand I'll focus on the problem. > > I have some event that should occur in 20% of all events. I thought > I'd make it easy by just using rand like following: > num = 20 - rand(100) > if(num > 0) > do_stuff > end > > But "do_stuff" is by far not being called as often as I would like it > to. Is there any method or something that is more accurate with that > kind of stuff? As said in another answer, this is convoluted code, simply testing rand(100) < 20 is ok. To answer your original question, rand implementations don't do what most developers think they do : they are pseudo-random number generators and the randomness is not guaranteed for only one call to rand in a whole program. If you try to get a random value only once in your program, you should feed the number generator a truly random value (for example read 4 bytes from /dev/urandom on a modern Unix box and feed them as an Integer to the generator through Kernel.srand). Lionel -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Colin Law wrote: > On 21 March 2010 15:25, Jagmit Gabba < lists@ruby-forum.com> wrote: >> � � �flash[:notice] = "Please Login to view this page, or Register if >> flash message is displayed. >> >> When the user is logged in, i want it to redirect the "user/register" >> and "user/login" to the "user/index", and if they are NOT logged in, >> they can view them. I have done this with the IF command in my menu but >> physically they can type the address aka user/register or user/login and >> view them again. > > You have already shown us how you redirect from index to login if the > user is not logged in. You are asking how to redirect from register > and login if not logged in. Just use basically the same technique but > the test will be the the other way round ('if' instead of 'unless'). > > Colin Thank you very much Colin,
Simple code: if session[:user_id] flash[:notice] = "Already registed and logged in! You cannot view the register or login!" redirect_to :action => :index end end Thank you for making me understand :D -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Dear spreers, My customer wants a products review system, that should be integrated with some forum engine. Does anybody have an experience of integrating spree with a forum? For me it sounds like quite some work. Could you think of a simpler solution? my best, Kostya -- You received this message because you are subscribed to the Google Groups "Spree" group. To post to this group, send email to spree-user@googlegroups.com. To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.
Read More…
Quoting Jeffrey L. Taylor < ror@abluz.dyndns.org>: [snip] > I dumped the first line into irb and tried it. It looked like do_stuff > wouldn't be called often enough, so I actually counted the occurrences and > crunched the numbers. They were within a reasonable distance of 1 in 5. I > suggest actually running the code and counting the occurrences. I suspect > you'll find that 20% is less often then it seems. > Oops, change to "less often than it seems." Jeffrey -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Quoting Heinz Strunk < lists@ruby-forum.com>: > Hello, > > I'm working with probability and Ruby doesn't really does as I want. > Just to make it easier to understand I'll focus on the problem. > > I have some event that should occur in 20% of all events. I thought I'd > make it easy by just using rand like following: > num = 20 - rand(100) > if(num > 0) > do_stuff > end > > But "do_stuff" is by far not being called as often as I would like it > to. Is there any method or something that is more accurate with that > kind of stuff? > The code looks correct, though a bit hard to understand. If it were my code, I might refactor it like this: do_stuff if rand(100) < 20 I dumped the first line into irb and tried it. It looked like do_stuff wouldn't be called often enough, so I actually counted the occurrences and crunched the numbers. They were within a reasonable distance of 1 in 5. I suggest actually running the code and counting the occurrences. I suspect you'll find that 20% is less often then it seems. HTH, Jeffrey -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
On 21 March 2010 15:59, Jagmit Gabba < lists@ruby-forum.com> wrote: > Logging out feature, > > Code: > > def logout > @title = "Login - Books" > > session[:user_id] != nil Do you mean session[:user_id] = nil Colin > flash[:notice] = "You have sucessfully been logged out !" > redirect_to :controller => :books, :action => :index > end > end > > ^^when this is run, it logs the user out (nill) and displays you have > successfully been logged out, > > Code v2: > def logout > @title = "Login - Books" > > session[:user_id] != nil > flash[:notice] = "You have sucessfully been logged out > #{@user.screen_name} !" > redirect_to :controller => :books, :action => :index > end > end > > ^^what i was hoping this would do is to display the users name as well, > (this is another task), i understand the session but how can i bring the > session back while the session is nill :S > > thanks once again mates, > > Jagmit Gabba > -- > 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-talk@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Quoting Jagmit Gabba < lists@ruby-forum.com>: > Jeffrey L. Taylor wrote: > > Quoting Jagmit Gabba < lists@ruby-forum.com>: > >> end > >> flash[:notice] = "You have sucessfully been logged out > >> #{@user.screen_name} !" > >> redirect_to :controller => :books, :action => :index > >> end > >> end > >> > >> ^^what i was hoping this would do is to display the users name as well, > >> (this is another task), i understand the session but how can i bring the > >> session back while the session is nill :S > >> > > > > Where is the instance variable @user set? If it were my code, I'd do > > something like this: > > > > def logout > > @title = "Login - Books" > > > > name = User.find(session[:user_id]) > > session[:user_id] != nil > > flash[:notice] = "You have sucessfully been logged out #{name}!" > > redirect_to :controller => :books, :action => :index > > end > > > > HTH, > > Jeffrey > > Good afternoon friend, > > Your code doesnt seem to be working as it gives me a SyntaxError, at the > end i added another end cause of the nill, it seems to work but the only > thing which is displayed is "You have successfully been logged out #!" > just that, no username. Oops, change: name = User.find(session[:user_id]) To: name = User.find(session[:user_id], :select => 'screen_name').screen_name Or maybe clearer:
def logout @title = "Login - Books" user = User.find(session[:user_id], :select => 'screen_name') session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out #{user.screen_name}!" redirect_to :controller => :books, :action => :index end And yes, you need the additional end to close the class. Jeffrey -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
The code snippet seems OK to me, although the code you have in the if block will happen 80% not 20% of the time, and it could be made a bit "slimmer". But you say it happens less than 20%? Tried this on by Ubuntu box with Ruby 1.8.7: irb(main):021:0> counter = 0 => 0 irb(main):022:0> 1000000.times{counter += 1 if rand(100) < 20} => 1000000 irb(main):023:0> puts String(Float(counter)/10000) + "%" 20.0002% => nil
So, given a million iterations, it seems to work OK, and gives the expected result of close to 20% hitrate. But if you still have problems, then I'm at a loss.... Some platform specific seeding issue perhaps? Well, hope this helps... :o) Regards, Rolf On Sun, Mar 21, 2010 at 5:12 PM, Heinz Strunk <lists@ruby-forum.com> wrote: Hello, I'm working with probability and Ruby doesn't really does as I want. Just to make it easier to understand I'll focus on the problem. I have some event that should occur in 20% of all events. I thought I'd make it easy by just using rand like following: num = 20 - rand(100) if(num > 0) do_stuff end But "do_stuff" is by far not being called as often as I would like it to. Is there any method or something that is more accurate with that kind of stuff? Thanks in advance! -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
On 21 March 2010 15:25, Jagmit Gabba < lists@ruby-forum.com> wrote: > I have several questions and i need clear understanding on how i should > approach them, my target is for creating something called "fakebook", > facebooks copy but not going live at all (uni project). > > Security Question > This is the code that helps me protect my "user/index".. > > private > def protect > unless session[:user_id] > flash[:notice] = "Please Login to view this page, or Register if > you do not have an account!" > redirect_to :action => :login > return false > end > end > > It works perfectly, as it checks for the session ID and when it finds > the user is logged in, he can view the user/index (another code is > placed on top with this). > Otherwise, they cannot view it and it takes them to the login page and a > flash message is displayed. > > When the user is logged in, i want it to redirect the "user/register" > and "user/login" to the "user/index", and if they are NOT logged in, > they can view them. I have done this with the IF command in my menu but > physically they can type the address aka user/register or user/login and > view them again. You have already shown us how you redirect from index to login if the user is not logged in. You are asking how to redirect from register and login if not logged in. Just use basically the same technique but the test will be the the other way round ('if' instead of 'unless'). Colin -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Hi all! I'm playing with Rails 3, and on one of my controllers I have the following update method defined: def update @category = @user.categories.find(params[:id]) @category.update_attributes(params[:ecategory]) @category.save respond_with @category end I'm using Jquery to interact with the controllers, and when I do an ajax PUT, the update action is correctly executed (the fields are updated), but the action returns an empty JSON object, which causes the Jquery ajax function to fall into an error. I'm I doing something wrong? Thank you all, Fabio. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Jeffrey L. Taylor wrote: > Quoting Jagmit Gabba < lists@ruby-forum.com>: >> end >> flash[:notice] = "You have sucessfully been logged out >> #{@user.screen_name} !" >> redirect_to :controller => :books, :action => :index >> end >> end >> >> ^^what i was hoping this would do is to display the users name as well, >> (this is another task), i understand the session but how can i bring the >> session back while the session is nill :S >> > > Where is the instance variable @user set? If it were my code, I'd do > something like this: > > def logout > @title = "Login - Books" > > name = User.find(session[:user_id]) > session[:user_id] != nil > flash[:notice] = "You have sucessfully been logged out #{name}!" > redirect_to :controller => :books, :action => :index > end > > HTH, > Jeffrey Good afternoon friend, Your code doesnt seem to be working as it gives me a SyntaxError, at the end i added another end cause of the nill, it seems to work but the only thing which is displayed is "You have successfully been logged out #!" just that, no username. -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
NEVER MIND. I was being an idiot. I just deleted the old migration file that was causing the problems; and then created a new migration file to get the new stuff in.. Thanks Guys, -Joe On Mar 21, 4:25 pm, yout...@dev-hq.co.uk wrote: > Ok, So I figure I have to roll the database back and then migrate it > again. > > However it just isnt doing anything when I call "rake db:rollback", or > even specify a STEP: > > >rake db:rollback STEP=4 > > (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog)>rake db:rollback STEP=10 > > (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog)>rake db:migrate > > (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) > == CreateCategories: migrating > =============================================== > -- create_table(:categories) > rake aborted! > An error has occurred, this and all later migrations canceled: > > SQLite3::SQLException: table "categories" already exists: CREATE TABLE > "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" > varchar(255), "image" varchar(255), "created_at" datetime, > "updated_at" datetime) > > (See full trace by running task with --trace) > > I just cant figure out why it wont rollback... > > Please Help, > > Thanks In Advance, > > Joe > > On Mar 21, 2:26 pm, Colin Law <clan...@googlemail.com> wrote: > > > On 21 March 2010 13:40, <yout...@dev-hq.co.uk> wrote: > > > > Ok, I seem to have a problem already. > > > > So first of all with these things, can I just change it in db/migrate/ > > > WhateverFile.rb ? > > > Then when I have changed it how do I put these changes into action? > > > I suggest you have a look at the rails guides athttp://guides.rubyonrails.org/. Start with Getting Started, not > > surprisingly, then the next one is Database Migrations which should > > sort out your current problems. Then move on and work you way through > > the others. > > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > > Colin -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Thanks Mark and Max On Mar 20, 10:40 pm, Mark McConachie <m...@markmcconachie.com> wrote: > Great blog, I have forwarded this to some beginners I know. > > On Mar 19, 3:52 pm, pankaj <pankajbhage...@gmail.com> wrote: > > > Hello Everyone, > > I have started my blog athttp://railsguru.org. > > Besides other stuff on Rails, the main focus of the site will be to > > help beginners to learn Ruby and Rails and build the fundamentals. > > > Regards, > > Pankaj Bhageria, > > Tech Lead, Sumeru Software Solutions.http://www.railsguru.orghttp://www.sumeru.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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Ok, So I figure I have to roll the database back and then migrate it again. However it just isnt doing anything when I call "rake db:rollback", or even specify a STEP: >rake db:rollback STEP=4 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:rollback STEP=10 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:migrate (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) == CreateCategories: migrating =============================================== -- create_table(:categories) rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) I just cant figure out why it wont rollback...
Please Help, Thanks In Advance, Joe On Mar 21, 2:26 pm, Colin Law <clan...@googlemail.com> wrote: > On 21 March 2010 13:40, <yout...@dev-hq.co.uk> wrote: > > > Ok, I seem to have a problem already. > > > So first of all with these things, can I just change it in db/migrate/ > > WhateverFile.rb ? > > Then when I have changed it how do I put these changes into action? > > I suggest you have a look at the rails guides athttp://guides.rubyonrails.org/. Start with Getting Started, not > surprisingly, then the next one is Database Migrations which should > sort out your current problems. Then move on and work you way through > the others. > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > Colin -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Ok, So I figure I have to roll the database back and then migrate it again. However it just isnt doing anything when I call "rake db:rollback", or even specify a STEP: >rake db:rollback STEP=4 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:rollback STEP=10 (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) >rake db:migrate (in C:/Users/user/Documents/Aptana Studio Workspace/ProductCatalog) == CreateCategories: migrating =============================================== -- create_table(:categories) rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "categories" already exists: CREATE TABLE "categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "image" varchar(255), "created_at" datetime, "updated_at" datetime) (See full trace by running task with --trace) I just cant figure out why it wont rollback...
Please Help, Thanks In Advance, Joe On Mar 21, 2:26 pm, Colin Law <clan...@googlemail.com> wrote: > On 21 March 2010 13:40, <yout...@dev-hq.co.uk> wrote: > > > Ok, I seem to have a problem already. > > > So first of all with these things, can I just change it in db/migrate/ > > WhateverFile.rb ? > > Then when I have changed it how do I put these changes into action? > > I suggest you have a look at the rails guides athttp://guides.rubyonrails.org/. Start with Getting Started, not > surprisingly, then the next one is Database Migrations which should > sort out your current problems. Then move on and work you way through > the others. > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > Colin -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Sounds good to me. -- Radiant CMS Dev Mailing List Post: radiantcms-dev@googlegroups.com Unsubscribe: radiantcms-dev-unsubscribe@googlegroups.com Group Site: http://groups.google.com/group/radiantcms-dev/ To unsubscribe from this group, send email to radiantcms-dev+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Read More…
Quoting Jagmit Gabba < lists@ruby-forum.com>: > Logging out feature, > > Code: > > def logout > @title = "Login - Books" > > session[:user_id] != nil > flash[:notice] = "You have sucessfully been logged out !" > redirect_to :controller => :books, :action => :index > end > end > > ^^when this is run, it logs the user out (nill) and displays you have > successfully been logged out, > > Code v2: > def logout > @title = "Login - Books" > > session[:user_id] != nil > flash[:notice] = "You have sucessfully been logged out > #{@user.screen_name} !" > redirect_to :controller => :books, :action => :index > end > end > > ^^what i was hoping this would do is to display the users name as well, > (this is another task), i understand the session but how can i bring the > session back while the session is nill :S > Where is the instance variable @user set? If it were my code, I'd do something like this: def logout @title = "Login - Books" name = User.find(session[:user_id]) session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out #{name}!" redirect_to :controller => :books, :action => :index end HTH, Jeffrey -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Hello, I'm working with probability and Ruby doesn't really does as I want. Just to make it easier to understand I'll focus on the problem. I have some event that should occur in 20% of all events. I thought I'd make it easy by just using rand like following: num = 20 - rand(100) if(num > 0) do_stuff end But "do_stuff" is by far not being called as often as I would like it to. Is there any method or something that is more accurate with that kind of stuff? Thanks in advance! -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Logging out feature, Code: def logout @title = "Login - Books" session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out !" redirect_to :controller => :books, :action => :index end end ^^when this is run, it logs the user out (nill) and displays you have successfully been logged out, Code v2: def logout @title = "Login - Books" session[:user_id] != nil flash[:notice] = "You have sucessfully been logged out #{@user.screen_name} !" redirect_to :controller => :books, :action => :index end end ^^what i was hoping this would do is to display the users name as well, (this is another task), i understand the session but how can i bring the session back while the session is nill :S thanks once again mates, Jagmit Gabba -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
Leonardo Mateo wrote: > On Sun, Mar 21, 2010 at 12:25 PM, Jagmit Gabba < lists@ruby-forum.com> > wrote: >> � � �flash[:notice] = "Please Login to view this page, or Register if >> flash message is displayed. >> > I'd strongly suggest you to take a look at Authlogic[1] gem. Even when > this is a very simple/personal project, and implement this gem might > look too much overhead for you, you'll get very interesting concepts > for authentication. > > [1] http://github.com/binarylogic/authlogic> > Hope it helps. > > > -- > Leonardo Mateo. > There's no place like ~ Thank you for your reply, i am a very basic student and i need to take it one bit a time. This was small homework set, ill have to take it small steps before i can leap. Would love a simple answer so i can understand it. Thanks once again, Jagmit Gabba -- 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-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
And remember to use http://railscasts.com/Great for getting started. /SG On Mar 21, 3:26 pm, Colin Law <clan...@googlemail.com> wrote: > On 21 March 2010 13:40, <yout...@dev-hq.co.uk> wrote: > > > Ok, I seem to have a problem already. > > > So first of all with these things, can I just change it in db/migrate/ > > WhateverFile.rb ? > > Then when I have changed it how do I put these changes into action? > > I suggest you have a look at the rails guides athttp://guides.rubyonrails.org/. Start with Getting Started, not > surprisingly, then the next one is Database Migrations which should > sort out your current problems. Then move on and work you way through > the others. > > The ones on ActiveRecord Associations and Debugging are compulsory reading. > > Colin -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
On Sun, Mar 21, 2010 at 12:25 PM, Jagmit Gabba < lists@ruby-forum.com> wrote: > I have several questions and i need clear understanding on how i should > approach them, my target is for creating something called "fakebook", > facebooks copy but not going live at all (uni project). > > Security Question > This is the code that helps me protect my "user/index".. > > private > def protect > unless session[:user_id] > flash[:notice] = "Please Login to view this page, or Register if > you do not have an account!" > redirect_to :action => :login > return false > end > end > > It works perfectly, as it checks for the session ID and when it finds > the user is logged in, he can view the user/index (another code is > placed on top with this). > Otherwise, they cannot view it and it takes them to the login page and a > flash message is displayed. > > When the user is logged in, i want it to redirect the "user/register" > and "user/login" to the "user/index", and if they are NOT logged in, > they can view them. I have done this with the IF command in my menu but > physically they can type the address aka user/register or user/login and > view them again. > > How can i redirect this? > > thank you for your help! > I'd strongly suggest you to take a look at Authlogic[1] gem. Even when this is a very simple/personal project, and implement this gem might look too much overhead for you, you'll get very interesting concepts for authentication. [1]http://github.com/binarylogic/authlogic Hope it helps. -- Leonardo Mateo. There's no place like ~
-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…
I went through the same steps, had to upgraded spree to 0.10.1 and finally was able to run the server. But now when I'm trying to use paypal express plugin have two problems: 1) "Continue" button is still there. 2) when I click on paypal button I get "Gateway Error ... Security header is not valid" error. I configured paypal express details but not sure about sever field. What does it do? Thanks Alex On Mar 11, 8:55 pm, Brian Quinn <br...@railsdog.com> wrote: > I just done a clean install based on 0.10.0 beta, installed the PPE > extension and the server started no problem. > > Can you check the following: > > 1 - you've installed the 0.10.0 ( gem list | grep spree ) > > 2 - you're environment.rb file has been updated, line 8 should read: > > SPREE_GEM_VERSION = '0.10.0.beta' unless defined? SPREE_GEM_VERSION > > 3 - make sure there's no pending migrations (rake db:migrate) > > On 10 March 2010 22:13, Sean Schofield <s...@railsdog.com> wrote: > > > > > > > Brian Quinn has taken the lead on PPE but he's going all out on two > > client launches for us. I'll ask him to take a few minutes tomorrow > > to field questions when he gets a chance. Please be patient. We're > > also working hard on a new release for this weekend and also another > > very big surprise to be announced in the next few days. We'll get it > > squared away - we're committed to maintaining a proper PPE extension > > and this is just the first pass. > > > Sean Schofield > > > ------------------------------------------- > > Rails Dog LLC > > 2 Wisconsin Circle, Suite 700 > > Chevy Chase, MD 20815 > > voice: (301)560-2000 > > ------------------------------------------- > > > On Wed, Mar 10, 2010 at 3:44 PM, Bryan.Taylor <btaylo...@gmail.com> wrote: > > > I'm still experiencing the same issue as well. Not sure why devs are > > > doing commit's when the extension is straight up broken. > > > > -bt > > > > On Mar 9, 2:28 pm, Jennifer Maas <jenniferm...@gmail.com> wrote: > > >> Same problem with 0.10.0 beta > > > >> On Mar 9, 9:40 am, Jennifer Maas <jenniferm...@gmail.com> wrote: > > > >> > I am using 9.4 . Do we need to be at 10 for this extension to work? > > > >> > On Mar 7, 8:24 pm, "Bryan.Taylor" <btaylo...@gmail.com> wrote: > > > >> > > So I've installedpaypalexpress using script/extension install > > >> > > git://github.com/railsdog/spree-paypal-express.git and restarted my > > >> > > site by killing dispatch.fcgi, but when I run script/server, I am > > >> > > receiving this error: > > > /home/veevecos/veeveShop/vendor/extensions/paypal_express/app/models/ > > >> > > billing_integration/paypal_express.rb:1: superclass must be a Class > > >> > > (Module given) (TypeError) > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:380:in > > >> > > `load_without_new_constant_marking'without_new_constant_marking' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:380:in `load_file' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:521:in `new_constants_in' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:379:in `load_file' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:259:in `require_or_load' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:425:in `load_missing_constant' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:80:in `const_missing' > > >> > > from > > /home/veevecos/veeveShop/vendor/extensions/paypal_express/ > > >> > > paypal_express_extension.rb:10:in `activate' > > >> > > from /usr/lib/ruby/gems/1.8/gems/spree-0.9.4/lib/spree/ > > >> > > extension.rb:34:in `activate' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:145:in `to_proc' > > >> > > from /usr/lib/ruby/gems/1.8/gems/spree-0.9.4/lib/spree/ > > >> > > extension_loader.rb:95:in `each' > > >> > > from /usr/lib/ruby/gems/1.8/gems/spree-0.9.4/lib/spree/ > > >> > > extension_loader.rb:95:in `activate_extensions' > > >> > > from /usr/lib/ruby/gems/1.8/gems/spree-0.9.4/lib/spree/ > > >> > > initializer.rb:132:in `after_initialize' > > >> > > from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/ > > >> > > initializer.rb:179:in `process' > > >> > > from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/ > > >> > > initializer.rb:113:in `send' > > >> > > from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/ > > >> > > initializer.rb:113:in `run' > > >> > > from /usr/lib/ruby/gems/1.8/gems/spree-0.9.4/lib/spree/ > > >> > > initializer.rb:97:in `run' > > >> > > from /home/veevecos/veeveShop/config/environment.rb:14 > > >> > > from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: > > >> > > 31:in `gem_original_require' > > >> > > from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: > > >> > > 31:in `require' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:156:in `require' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:521:in `new_constants_in' > > >> > > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/ > > >> > > active_support/dependencies.rb:156:in `require' > > >> > > from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/ > > >> > > server.rb:84 > > >> > > from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: > > >> > > 31:in `gem_original_require' > > >> > > from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: > > >> > > 31:in `require' > > >> > > from script/server:3 > > > >> > > Have you experienced this error? Any idea how I can resolve it? > > > >> > > Thanks. > > > >> > > On Feb 25, 2:41 am, Paul Callaghan <p...@railsdog.com> wrote: > > > >> > > > > When you say pull an earlier version, are you talking about > > Spree or the > > >> > > > >paypal-express extension? > > > >> > > > Oops - I meant the extension; so go for the revision before > > yesterday's > > >> > > > additions. > > > >> > > > Also, is there a good guide to RoR> initializers that you have > > referenced before? I'm just looking for as > > >> > > > > many good RoR resources and Spreesources as possible :) > > > >> > > > Take a look at code - eg the spree-demo contains useful examples > > (although > > >> > > > it's a bit out of date now). > > > >> > > > Paul > > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Spree" group. > > > To post to this group, send email to spree-user@googlegroups.com. > > > To unsubscribe from this group, send email to > > spree-user+unsubscribe@googlegroups.com<spree-user%2Bunsubscribe@googlegrou ps.com> > > . > > > For more options, visit this group at > >http://groups.google.com/group/spree-user?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Spree" group. > > To post to this group, send email to spree-user@googlegroups.com. > > To unsubscribe from this group, send email to > > spree-user+unsubscribe@googlegroups.com<spree-user%2Bunsubscribe@googlegrou ps.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/spree-user?hl=en. > > -- > Brian Quinn > > ------------------------------------------- > Rails Dog LLC > 2 Wisconsin Circle, Suite 700 > Chevy Chase, MD 20815 > voice: (301)560-2000 > -------------------------------------------
-- You received this message because you are subscribed to the Google Groups "Spree" group. To post to this group, send email to spree-user@googlegroups.com. To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.
Read More…
|