Re: serving static files
Hi Ben, I apologize for the late reply. For some reason your reply went to the spam folder. Anyway, your solution works perfectly:) Thank you! regards, Seba 2015-03-23 20:15 GMT+01:00 Ben Schumacher m...@benschumacher.com: Sebastian- It's hard to guess what the issue with Camping is without a little more detail. You could achieve the same result by having Rack serve the static files, and skip Camping altogether. Something like this in your config.ru: require 'app' use Rack::Static, :urls = ['/static', ], :root = 'parent-of-static' run Rack::Adapter::Camping.new(app) Hope this helps, BEn On 3/23/15 6:40 AM, Sebastjan Hribar wrote: Hi, I have a problem with serving static files in my app. I use the code as shown here ( https://github.com/judofyr/camping/wiki/Serving-Static-Files). I had to remove the @ sign for FILE to make it work. For now I'm only serving one background image: -- #index_main { background-size: cover; background-image: url(static/slika2.jpg) } -- When I do this in my windows running from command line the image is served. When I do this in windows server 2008 running as a service, the image is not shown and if I try accessing it like address:3301/static/slika2.jpg I get this error: Camping Problem! /static/slika2.jpg not found I'm using config.ru like so: $LOAD_PATH File.expand_path('..') require './app_name' app_name.create run app_name Should I add anything for the static files in config.ru as well? I use thin as the server. thank you! regards, seba ___ Camping-list mailing listCamping-list@rubyforge.orghttp://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
serving static files
Hi, I have a problem with serving static files in my app. I use the code as shown here ( https://github.com/judofyr/camping/wiki/Serving-Static-Files). I had to remove the @ sign for FILE to make it work. For now I'm only serving one background image: -- #index_main { background-size: cover; background-image: url(static/slika2.jpg) } -- When I do this in my windows running from command line the image is served. When I do this in windows server 2008 running as a service, the image is not shown and if I try accessing it like address:3301/static/slika2.jpg I get this error: Camping Problem! /static/slika2.jpg not found I'm using config.ru like so: $LOAD_PATH File.expand_path('..') require './app_name' app_name.create run app_name Should I add anything for the static files in config.ru as well? I use thin as the server. thank you! regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
authentication system in camping error
Hi guys, I've just posted a question on SO regarding the authentication system I've setup in my camping app and I can't resolve the error by myself. I don't think it's related to camping itself, but maybe to AR or something else. If anyone wants to have a look, here's the link: http://stackoverflow.com/questions/29054151/authentication-fails-in-camping-web-app-after-attribute-update. Direct link to my gist is here: https://gist.github.com/sebastjan-hribar/38b5b640ffd29d96cc70. The problem is that user authentication fails after user attribute has been updated in the database. Prior to that, everything works fine. thank you for your help, regards seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: problems with console - uninitialized constant
Hi Paul, you're right. I've mixed the two:( It works now. regards Seba Dne 09. 03. 2015 ob 21:29 je Paul van Tilburg zapisal(a): On Mon, Mar 09, 2015 at 07:24:38PM +0100, Sebastjan Hribar wrote: I'm having problems with the console. When I try to create a new user, I get this error: 2.1.5 :001 user = User.new(username: hribar, email: s...@test.com, password: qwert, password_confirmation: qwert) NameError: uninitialized constant User Yes, this is normal. Unlike the Rails console, the Camping console does not include the model module. So, you probably need to do: include MyApp::Models Object first. Paul ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
problems with console - uninitialized constant
Hi, I'm having problems with the console. When I try to create a new user, I get this error: 2.1.5 :001 user = User.new(username: hribar, email: s...@test.com, password: qwert, password_confirmation: qwert) NameError: uninitialized constant User from (irb):1 from /home/sebastjan/.rvm/gems/ruby-2.1.5/gems/camping-2.1.532/lib/camping/server.rb:138:in `start' from /home/sebastjan/.rvm/gems/ruby-2.1.5/gems/rack-1.6.0/lib/rack/server.rb:147:in `start' from /home/sebastjan/.rvm/gems/ruby-2.1.5/gems/camping-2.1.532/bin/camping:9:in `top (required)' from /home/sebastjan/.rvm/gems/ruby-2.1.5/bin/camping:23:in `load' from /home/sebastjan/.rvm/gems/ruby-2.1.5/bin/camping:23:in `main' from /home/sebastjan/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval' from /home/sebastjan/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `main' Why is the reported User uninitialized? regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
migrations issues
Hi, I'm still having problem with running migrations. I've tried the code below: class FormStatusField V 1.1 def self.up add_column(Reviewform.table_name, :status, :string) Reviewform.reset_column_information end def self.down remove_column(Reviewform.table_name, :status) end end And with ActiveRecord 4.0.4 this gives me the error below: NoMethodError at /form/new undefined method `status' for #Review::Models::Reviewform:0x0002ca27c0 Ruby |/home/sebastjan/.rvm/gems/ruby-2.1.5/gems/activemodel-4.0.4/lib/active_model/attribute_methods.rb|: in|method_missing|, line 439 Web |GET localhost/form/new| The column is not added which I confirm by browsing the sql table. I've tried the later AR version, namely 4.2.0 and I can't even run the initial migration. I guess this is related to this issue https://github.com/camping/camping/issues/77. As this problem in general is probably related to AR, can someone confirm for which AR version migrations run fine. This is crucial to my app as I need to deploy it productively this month and currently I can bypass this issue only by switching databases and refactor the initial migration. Additional note: this code from the book also didn't work | ||class AddTagColumn V 1.1| | ||def self.change| | ||add_column Page.table_name, :tag, :string| | ||Page.reset_column_information| | ||end| | ||end| regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: camping with prawn
I was confused with two options: generating a PDF view template and saving to PDF. I've successfully implemented the latter with the below changes to my view: def showpdf if File.exist?(#{@reviewform.title}.pdf) h4 PDF-document already exists. else pdf = Prawn::Document.new pdf.text #{@reviewform.title} pdf.render_file #{@reviewform.title}.pdf h4 PDF-document was successfully saved. end end This is just basic stuff to test it. Can someone still confirm this is the right way, and how would I go about the view template method so when the user visits this view, the pdf format would be rendered and then they could save that? regards, seba Dne 01. 12. 2014 ob 20:20 je Sebastjan Hribar zapisal(a): Hi guys, can someone help me with this challenge. I'd like to be able to save reviewforms from my app to PDF files. I'm struggling because there is no explicit examples, but I try to derive the correct way from rails examples. So, I've made this: I've created a separate controller for showing a reviewform in a PDF format: class ShowPdfN def get(form_id) if @state.username @reviewform = Reviewform.find(form_id) render :showpdf else redirect Login end end end And the view with basic stuff: def showpdf pdf = Prawn::Document.new pdf.text #{@reviewform.title} end When I wisit http://localhost:3301/show/pdf/1 there is nothing to display. Any ideas? regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
small custom erp - can I do it in camping
Hi, I need advice before I decide to start my next project. Since camping is intended for smaller apps I'm not sure whether I should try to use it for my small custom erp app. _Here's what I had in mind:_ create several apps for separate erp modules or submodules even and have them use the same database. Since I'm very pleased with my first camping app for quality assurance which we use productively I'd like to just add all modules. _Size:_ - 4 additional main modules with (currently) 22 models Could I pull this off in camping or must I consider rails? regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
ActiveRecord - issues with schema
Hi, My apps recently stopped working. Right after I launch the server I get (errors from sample app) ActiveRecord::RecordNotFound at / Couldn't find Test::Models::SchemaInfo with 'id'=firstRuby /home/sebastjan/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.5/lib/active_record/relation/finder_methods.rb: in raise_record_not_found_exception!, line 320 and upon refresh TypeError at / superclass mismatch for class BasicFieldsRubytest.rb: in module:Models, line 10 I've noticed this recently when I started deploying with phusion passenger and I thought the issue was related to passenger (admittedly, one of the issues was:) Then, the only thing I could come up with that could be the cause is the AR as I've updated it because I've started learning rails. gem list shows: ... activemodel (4.1.5, 4.0.4) activerecord (4.1.5, 4.0.4) activerecord-deprecated_finders (1.0.3) activesupport (4.1.5, 4.0.4, 2.3.18) ... Are my assumptions about AR correct? Because I haven't made any changes to the code itself. Also, .camping.db contains schemas for separate apps, however each table only has the id and version fields. It seems migrations are not running at all? If the problem is in AR, how can I use older version for camping and newer for rails? Thank you for your help. regards seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: app doesn't run on windows
Hi, unfortunatelly I had to postpone deployment on Windows, but I also had no luck yet with sqlite on windows either. When I continue I think we'll go with the linux server to deploy the app. I'll post if we do it in windows environtment. regards seba 2014-06-07 18:31 GMT+02:00 Magnus Holm judo...@gmail.com: Did you find a solution? It's been a while since I've been testing Camping on Windows, so I'm not quite sure how to set up SQLite properly. // Magnus On Friday, May 16, 2014, Sebastjan Hribar sebastjan.hri...@gmail.com wrote: Note: the error is caused by not having sqlite setup properly in windows and I'm still struggeling:( The app itself is fine. regards seba 2014-05-15 10:37 GMT+02:00 Sebastjan Hribar sebastjan.hri...@gmail.com: Hi, I have problem running the app in windows. This is the app I've asked question about recently (the review app). It runs ok in my linux mint debian edition, but on windows it doesn't. First issue was with encoding. Even if I've set the meta charset it didn't work. Now I've also set the enocoding to the utf-8 in the .rb file itself and I don't get any more errors. But I do get this error: Camping Problem! / not found And that's it. No other info. The app is exactly the same as the one running in LMDE. Could this issue be related to the campging.db? I can't find it on windows. Is it possible tha camping is denied the access to the folder where it should be created? regards, seba -- // Magnus Holm ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: first app - some questions
Thank you for the detailed description! I have one question about the @state. Where does the method user_id come from? I've been going through the unabridged source and Camping::Session reference, but I guess I'm not proficient enough:) And what else can be also saved in the @state? regards seba 2014-06-07 18:42 GMT+02:00 Magnus Holm judo...@gmail.com: On Saturday, May 3, 2014, Sebastjan Hribar sebastjan.hri...@gmail.com wrote: Hi guys, just a little feedback from a beginner. I've finished my first camping app. Thank you for your help and guidance. The finished app is about quality management and enables users to fill out forms. Based on those forms different quality parameters are recorded per user and per project. These can be called up in summary reports for desired time frame and user. Along with all the forms for a period the average quality evaluation is also displayed. Reports can only be generated by quality managers. I've managed to reuse only one html form for creating, viewing and editing. In addition, I've setup the form in such a way, that submitting is possible only when the form was called via »new« or »edit« route and the user has appropriate authorizations. I have one question regarding the session. I don't actually know how to leverage or use it. According to the reference the session adds states to the app. Can someone explain a bit more? Sorry for the late reply. Here's an example of state: module App::Controllers class Index def get if @state.user_id Welcome user number #{@state.user_id} else render :login end end class Login def post # Just log everyone in. No passwords here! @state.user_id = @input.user_id redirect Index end end end module App::Views def login form action: R(Login), method: :post do label do p User ID: input name: :user_id end button Log in end end end Here's an example of the flow when the user visits the site: 1. User visits GET /. Index#get is called. 2. The state is empty, so the #login view is rendered 3. The user enters his user ID (let's say 5). 4. When the user presses Log in, the browser will do a POST /login with user_id=5 as parameters 5. Login#post is invoked. This sets the state variable and then redirects to /. 6. The user's browser then shows GET /. Now he gets a welcome message, not the login form. Notice how the same request is done in both step 1 and 6 (GET /), but the second time the user gets a completely different page. That's because the state is different. You might know about cookies: sessions are like cookies that only the server know how to set. It's impossible for the client to set its own session; every session has to be set through the @state-variable in an action. I hope this clarifies state/sessions a bit. Don't hesitate to ask more if you're confused. // Magnus -- // Magnus Holm ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
app doesn't run on windows
Hi, I have problem running the app in windows. This is the app I've asked question about recently (the review app). It runs ok in my linux mint debian edition, but on windows it doesn't. First issue was with encoding. Even if I've set the meta charset it didn't work. Now I've also set the enocoding to the utf-8 in the .rb file itself and I don't get any more errors. But I do get this error: Camping Problem!/ not found And that's it. No other info. The app is exactly the same as the one running in LMDE. Could this issue be related to the campging.db? I can't find it on windows. Is it possible tha camping is denied the access to the folder where it should be created? regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: multi-line input field
Hi, I can only use textarea rows:'5' @testform.testing for displaying pruposes. As soon as I use tag input which I need for saving the data to the database table, multiline is impossible. regards, seba 2014-05-12 13:39 GMT+02:00 David Susco dsu...@gmail.com: textarea rows:'5' @testform.testing doesn't do what you want it to do? On Mon, May 12, 2014 at 1:51 AM, Sebastjan Hribar sebastjan.hri...@gmail.com wrote: Hi, can someone tell me if multi-line input field is possible to do with markaby? If I use input tag like so: --- input type: 'textarea', name: 'testing', value: @testform.testing --- I can only set the length of the field by providing the size: attribute. If I use textarea tag like so: --- textarea @testform.testing --- it only make sense for displaying the value. I'd like to accomplish multi-line input field. The purpose of such a text box is to enter a bit longer comments. Can it be done? regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list -- Dave ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: multi-line input field
Here was my mistake: I thought that in order for setting the model attribute data like so: common_attributes = {title: input.title, ..., general_remark: input.general_remark} I have to explicitly state the input tag in the form like so: input textarea @reviewform.general_remark, rows: 5, name: 'general_remark' and this produced the error about tag not allowing the content. 3. Otherwise, I used it like so: input type: 'textarea', name: 'suggestions_reviewer_comments', value: @reviewform.suggestions_reviewer_comments And this didn't produce any errors, but on the other hand the field in the form had the same appearance as the 'text' field. Thank you again. regards, seba On 12. 05. 2014 15:45, Sebastjan Hribar wrote: My assumption was based on the behavior of my form in my app. I'll test the way magnus wrote it and I'll post back here later today so I won't make any false statements. In order to capture the data I always used the input tag and that didn't allow for multiple line textarea. regards, seba 2014-05-12 15:08 GMT+02:00 Bartosz Dziewoński matma@gmail.com mailto:matma@gmail.com: On Mon, 12 May 2014 14:49:33 +0200, Sebastjan Hribar sebastjan.hri...@gmail.com mailto:sebastjan.hri...@gmail.com wrote: I can only use textarea rows:'5' @testform.testing for displaying pruposes. Why? textarea is the way to do multiline text inputs in HTML. -- Matma Rex ___ Camping-list mailing list Camping-list@rubyforge.org mailto:Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: multi-line input field
But textarea isn't unknown or unspecified type, right? On 12. 05. 2014 18:19, Bluebie wrote: All web browsers will treat any unknown or unspecified type of input as being a text input. This is why we can have things like input type=email and it doesn't destroy everything :) --- Bluebie On Tuesday, 13 May 2014 at 1:57 am, Sebastjan Hribar wrote: Here was my mistake: I thought that in order for setting the model attribute data like so: common_attributes = {title: input.title, ..., general_remark: input.general_remark} I have to explicitly state the input tag in the form like so: input textarea @reviewform.general_remark, rows: 5, name: 'general_remark' and this produced the error about tag not allowing the content. 3. Otherwise, I used it like so: input type: 'textarea', name: 'suggestions_reviewer_comments', value: @reviewform.suggestions_reviewer_comments And this didn't produce any errors, but on the other hand the field in the form had the same appearance as the 'text' field. Thank you again. regards, seba On 12. 05. 2014 15:45, Sebastjan Hribar wrote: My assumption was based on the behavior of my form in my app. I'll test the way magnus wrote it and I'll post back here later today so I won't make any false statements. In order to capture the data I always used the input tag and that didn't allow for multiple line textarea. regards, seba 2014-05-12 15:08 GMT+02:00 Bartosz Dziewon'ski matma@gmail.com mailto:matma@gmail.com: On Mon, 12 May 2014 14:49:33 +0200, Sebastjan Hribar sebastjan.hri...@gmail.com mailto:sebastjan.hri...@gmail.com wrote: I can only use textarea rows:'5' @testform.testing for displaying pruposes. Why? textarea is the way to do multiline text inputs in HTML. -- Matma Rex ___ Camping-list mailing list Camping-list@rubyforge.org mailto:Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org mailto:Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: multi-line input field
Thank you very much for the explanation. I was puzzled why let's say input tag number requires this syntax: input type = 'number' and it breaks when written number @@reviewform.number, name: 'number. And the opposite is true for textarea. regards, seba On 12. 05. 2014 19:44, Bluebie wrote: textarea's are made using the textarea tag. There is no such thing as input type=textarea. Maybe this comes from rails or something? In markaby unless you've created some helpers to do otherwise, it outputs whatever you write in your code - a call to input() wont be transformed in to a textarea or a button or any other kind of form element. Markaby really is just a way of writing html, using ruby syntax instead of xml/sgml, and not much more. --- Bluebie On Tuesday, 13 May 2014 at 3:34 am, Sebastjan Hribar wrote: But textarea isn't unknown or unspecified type, right? On 12. 05. 2014 18:19, Bluebie wrote: All web browsers will treat any unknown or unspecified type of input as being a text input. This is why we can have things like input type=email and it doesn't destroy everything :) --- Bluebie On Tuesday, 13 May 2014 at 1:57 am, Sebastjan Hribar wrote: Here was my mistake: I thought that in order for setting the model attribute data like so: common_attributes = {title: input.title, ..., general_remark: input.general_remark} I have to explicitly state the input tag in the form like so: input textarea @reviewform.general_remark, rows: 5, name: 'general_remark' and this produced the error about tag not allowing the content. 3. Otherwise, I used it like so: input type: 'textarea', name: 'suggestions_reviewer_comments', value: @reviewform.suggestions_reviewer_comments And this didn't produce any errors, but on the other hand the field in the form had the same appearance as the 'text' field. Thank you again. regards, seba On 12. 05. 2014 15:45, Sebastjan Hribar wrote: My assumption was based on the behavior of my form in my app. I'll test the way magnus wrote it and I'll post back here later today so I won't make any false statements. In order to capture the data I always used the input tag and that didn't allow for multiple line textarea. regards, seba 2014-05-12 15:08 GMT+02:00 Bartosz Dziewon'ski matma@gmail.com mailto:matma@gmail.com: On Mon, 12 May 2014 14:49:33 +0200, Sebastjan Hribar sebastjan.hri...@gmail.com mailto:sebastjan.hri...@gmail.com wrote: I can only use textarea rows:'5' @testform.testing for displaying pruposes. Why? textarea is the way to do multiline text inputs in HTML. -- Matma Rex ___ Camping-list mailing list Camping-list@rubyforge.org mailto:Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org mailto:Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org mailto:Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org mailto:Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: first app - some questions
Hi guys, just a little feedback from a beginner. I've finished my first camping app. Thank you for your help and guidance. The finished app is about quality management and enables users to fill out forms. Based on those forms different quality parameters are recorded per user and per project. These can be called up in summary reports for desired time frame and user. Along with all the forms for a period the average quality evaluation is also displayed. Reports can only be generated by quality managers. I've managed to reuse only one html form for creating, viewing and editing. In addition, I've setup the form in such a way, that submitting is possible only when the form was called via »new« or »edit« route and the user has appropriate authorizations. I have one question regarding the session. I don't actually know how to leverage or use it. According to the reference the session adds states to the app. Can someone explain a bit more? regards, seba On 22. 04. 2014 21:27, Magnus Holm wrote: On Mon, Apr 21, 2014 at 7:32 PM, Sebastjan Hribar sebastjan.hri...@gmail.com wrote: Hi, I've updated the gist with my next version: https://gist.github.com/sebastjan-hribar/11081389 It works as I wanted but for now I left out the styling. My question is, is this the correct way of setting up routes? That looks fine. Although you can even simplify the Index-route like this: class Index # look, no R '/' end Can someone have a look and point out mistakes I've made. I mean the app works, but I'd like to know if (of better yet, how) the routing or anything else can be optimized. It looks fine to me :-) Secondly, when I'm done I'll need this to be running in a closed network. I'd need some advice on deployment. I can run it on a spare machine or a server even, but how what kind of configuration is required (ports, databases)...? If you want to run it on your own machine, I recommend using Phusion Passenger. Passenger (and other Ruby web server) requires a config.ru like this: $LOAD_PATH File.expand_path('..') require 'review' Review.create # remember to call your #create method here! run Review You can test this config.ru locally using the `rackup` tool: $ rackup -p 3301 If this works correctly you should also be able to point Passenger to the same file and everything should work properly! You can also deploy using Heroku when you have a working config.ru. As for configuration, the simplest thing is just checking for an environment variable in Review.create: def Review.create case ENV['RACK_ENV'] when 'production' # setup for production else # setup for development end end regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: views - html form duplication
Hi, thank you again for your help. Firstly, I should apologize for asking something that I could've derived from the blog example where partials are well structured and apparent. Secondly, in the pattern below I couldn't make sense of the _post_fields. How is this setup together? When I implemented def edit form :action = R(PostsNEdit), :method = :post do _post_fields end end ... I got bad route error. Then I fixed it by modifying the route like so: R(PostsNEdit, @post) and the I got undefined local variable or method `_post_fields' for #Test::Controllers::PostNEdit:0x007f1f95485128. Anyway, I went back and studied the partials and I've came up with this simple test app that works: https://gist.github.com/sebastjan-hribar/11371787 Another note, in the blog example in the line 96 the update_attributes method takes a hash, but I got an activerecord error, which indicated the method needs to have passed in the name and the key: @post.update_attribute(:title, input.title). The app in the gist works by having this implemented. regards, seba P.S.: I'm thinking of putting together a FAQ of all my beginner questions and answers provided (or those that I figured out myself). If it would be useful I can provide it when finished. On 24. 04. 2014 22:34, Magnus Holm wrote: On Thu, Apr 24, 2014 at 10:08 PM, Sebastjan Hribar sebastjan.hri...@gmail.com wrote: Hi, I have a question about duplicating a html form in my views. To create a new review form in the app I've composed a html form which is a table and I've ended up with 200+ lines of code due to table row and data blocks. This is the input review form for a user to fill out and submit. My question is about editing an already existing review form. Is there any way of avoiding the duplication of the html form and reusing the existing html form? As I understand the inly difference in the edit view is that I explicitly call the object attributes from the db and represent them in the input fields. If I can't avoid the duplication I'll end up with another 200+ lines and I should probably then separate my models, views and controllers into separate files. Right? This is a common pattern: class PostsNew def get @post = Post.new # new, empty Post-object render :new end end class PostsNEdit def get(id) @post = Post.find(id) render :edit end end module App::Views def edit form :action = R(PostsNEdit), :method = :post do _post_fields end end def new form :action = R(Posts), :method = :post do _post_fields end end def _form input :name = :title, :value = @post.title end end ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
views - html form duplication
Hi, I have a question about duplicating a html form in my views. To create a new review form in the app I've composed a html form which is a table and I've ended up with 200+ lines of code due to table row and data blocks. This is the input review form for a user to fill out and submit. My question is about editing an already existing review form. Is there any way of avoiding the duplication of the html form and reusing the existing html form? As I understand the inly difference in the edit view is that I explicitly call the object attributes from the db and represent them in the input fields. If I can't avoid the duplication I'll end up with another 200+ lines and I should probably then separate my models, views and controllers into separate files. Right? regards, seba P.S.: love camping:) ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: first app - some questions
Thank you very much for this valuable information. And I've stumble upon another problem: migrations. I want to add additional columns and my table in the database which is already set up (this is still development). I did as it's described in the camping book and put another migration with increased version number (I've deleted most columns here for brevity): class BasicFields V 1.0 def self.up create_table Reviewform.table_name do |t| t.string:title t.string:translator t.timestamps end end def self.down drop_table Reviewform.table_name end end class AdditionalBasicFields V 1.1 def self.change add_column Reviewform.table_name, :wrong_translation, :string Reviewform.reset_column_information end def self.down drop_table Reviewform.table_name end end --- And at the end of the file I have as usual: --- def Review.create Review::Models.create_schema end -- This throws this error at me when creating a new form: ActiveRecord::UnknownAttributeError at /form/new unknown attribute: wrong_translation Ruby /home/sebastjan/.rvm/gems/ruby-2.1.1/gems/activerecord-4.0.4/lib/active_record/attribute_assignment.rb: in rescue in _assign_attribute, line 47 WebPOST localhost/form/new I also tried doing this as described in ActiveRecord API: class AdditionalBasicFields V 1.1 def self.change change_table :reviewforms do |t| t.integer :wrong_translation end end def self.down drop_table Reviewform.table_name end end -- And I get the same error. The table is not changed. I can't find the mistake I've made. Need help:( regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: first app - some questions
Hi, I've updated the gist with my next version: https://gist.github.com/sebastjan-hribar/11081389 It works as I wanted but for now I left out the styling. My question is, is this the correct way of setting up routes? Can someone have a look and point out mistakes I've made. I mean the app works, but I'd like to know if (of better yet, how) the routing or anything else can be optimized. Secondly, when I'm done I'll need this to be running in a closed network. I'd need some advice on deployment. I can run it on a spare machine or a server even, but how what kind of configuration is required (ports, databases)...? regards, seba On 19. 04. 2014 13:22, Sebastjan Hribar wrote: Hi, I have a couple of questions: 1. What is the difference between these two ways of setting up migrations: 1.1 example from the camping book: - |class BasicFields V 1.0| |||def self.up| |||create_table Page.table_name do |t|| |.| |.| |.| - 1.2 Example from the blog example: class BasicFields V 1.1 def self.up create_table :blog_posts, :force = true do |t| --- Why the difference between Model.table_name and :campingapp_model and which one should I use? 2. UTF-8 encoding doesn't work. Special characters like c(, s(, z( from my language are not displayed. Should I force the encoding and how? 3. Here is the link to the gist where I've posted my first camping app skeleton for the quality reporting app I need to do. I'd really appreciate it if someone can have a look and just tell me if I'm on the right track with the understanding of the camping concept. https://gist.github.com/sebastjan-hribar/11081389 ...and Happy Easter! seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
camping tutorial pre-2
Hi Guys, I found this pre-2 tutorial on the ruby-camping-links.1.ai site: http://polzr.blogspot.com/2007/04/everythinginject-sum-post-sum-post-ii.html?view=timeslide I've gone through the code and typed it out to learn, but when I run the app I get the message / not found I've also copied the code as I might mistyped something and the result is the same. Any ideas? regards seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: camping tutorial pre-2
Hi, here is the gist: https://gist.github.com/anonymous/10878521 As a side note: I don't get replies to my mail box eventhoug I've subscribed to the mailing list. regards, seba 2014-04-16 13:14 GMT+02:00 Sebastjan Hribar sebastjan.hri...@gmail.com: Hi Guys, I found this pre-2 tutorial on the ruby-camping-links.1.ai site: http://polzr.blogspot.com/2007/04/everythinginject-sum-post-sum-post-ii.html?view=timeslide I've gone through the code and typed it out to learn, but when I run the app I get the message / not found I've also copied the code as I might mistyped something and the result is the same. Any ideas? regards seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
first project - relevance
Hi, Hopefully this mail wont duplicate as I've sent out one before I got the confirmation for subscription:) Here the original message: I'm new to camping, but not to ruby and I know about rails, but I've never used it apart from the learning blog app. I'm inspired by why's work as I use Shoes a lot and I was blown when I first saw camping. I really want to start using it and I'd like to ask you guys if my first learning project is suitable for camping. I need to make a webapp for quality control checks. I'd have 1 form and multiple users. In addition, some querying among forms would be needed to get the data about quality per product or user. To my understanding I could use camping for this and I don't have to use rails or something else. Am I correct? Kind regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
first project - relevance
Hi, I'm new to camping, but not to ruby and I know about rails, but I've never used it apart from the learning blog app. I'm inspired by why's work as I use Shoes a lot and I was blown when I first saw camping. I really want to start using it and I'd like to ask you guys if my first learning project is suitable for camping. I need to make a webapp for quality control checks. I'd have 1 form and multiple users. In addition, some querying among forms would be needed to get the data about quality per product or user. To my understanding I could use camping for this and I don't have to use rails or something else. Am I correct? Kind regards, seba ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list