I´m a begginer Rails developer and i´m into a trouble.
I have done an aplication for monitoring a sensor, and now i want to send the valus from an arduino board.
I wanto to create atomatically a record accesing to a url like "localhost/values/343#123" only form the local machine.
What´s the way? It´s is possible?
Thank You!!!
Just do a POST request via HTTP.
The Restful, Railsy way to to it would be to do a POST to the url ending in the pluralized name of the class of the record you want to create. So, "/values." As long as your values match columns in the Values table, you can use the Scaffold controllers, and you will create a new record with the values you pass.
Related
I am quite new in YII just 2 weeks and I am getting a hang on it, but I have an integration I have to do, which includes submitting form data to an enternal site, as well saving said data in my DB, after which i am automatically redirected to the said site and after performing some actions they send some data back, which should be displayed and saved in my DB as well. Any help would be grossly appreciated. Thanks
You will need cURL for the remote request: http://www.php.net/manual/en/curl.examples-basic.php.
Yii does not have this functionality by default, but you can create a component for it, which makes a post request to the remote site using cURL.
Depending on the format of the returned data, you will need to decode/unserialise it.
You can create a CDbCommand to store it directly into the database or assign values to an Active Record model and store that into the database.
I'm unsure of what to do here I would like to ask what process should I use or what are the web standards in accomplishing this.
Scenario:
A User inputs information (e.g. a classified ads post). How should I generate the page of the users post? Should I create a new page with the information provided by the user or should I create just one page that dynamically changes with the content requested?
Generally whats the process I should take?
I hear a lot of talk about using cms, but I think I can create my own simple "cms" that can provide my needs. But I need to know what direction should I use. Creating a NEW PAGE or Creating a SINGLE DYNAMIC PAGE?
I agree that you should be able to create your own "CMS" that will meet your needs. If I understand your question, I would definitely create one page that is dynamically loaded from the database. Think about the server load you could create if you created a new page for every entry. One of the things I advise every client that I develop a website for is to think about what they want their website to be doing for their business in 3 years. I would advise you to think through the same question and I believe you will see why I recommend using a dynamic page.
Good luck with your site.
I need a UI to manage all app sessions. How could I retrive data from foreign sessions? Im interested in getting data set bysetState` function during other users login.
I'm using CDbHttpSession for storing sessions in DB
So, i found answer, but it isnt good in my opinion. But maybe it will be helpfull for others. Yii stores data in session table using php built in session serialization method (it isnt regular serialize function). And only way that i found to work with it is suggested on the php session_decode manual page in the comments.
I'm about to create an application that uses JSON to update its content.
This is how I planned it to work:
When application starts, it checks (with internet connection is available) if the JSON file set on remote server is newer than the one stored localy - if it is then it's downloaded.
Then, the application applies data from that JSON to the content. For example, to the "Contact" information - it applies data like phone numbers etc.
My question is, is it in your opinion, a good technique to update appliactions content?
Does anynone had an experience with building app with this kind of idea?
Best regards,
Zin
Of course you can do this. One thing that may lead to a better user experience would be to ask the user for his permission to download new content (if there is something new).
This is a normal thing to do. I have a phonebook app that does exactly this. On a side note, if you need a network class to handle the web-service interaction, see this SO post. I wrote a custom network class that works with AFNetworking.
So first the user submit a form and will appear a new window in which you have a 5 step page
my aim is to create one submission procedure multi step form in which user can upload a file & etc..........
And so on.
It's much like an state-machine,
Don't know if my design is bad or if there's some correct way to do this?
Thanks.
I prefer using Jquery to handle this (via hiding and showing divs after various steps), that way there is one easy form with the multiple steps.
Server side multi step forms, afaik, are not available with Rails as they do not gel well with the whole RESTful architecture.
However you can create a key-value data store (memcache, flat file or a table) which has a key and stores data as value at each step in a hash. Keep pushing the data back to the server after each step and storing it in this hash. To go back to previous steps, you can devise the URL of the form as ///. Key can be a UUID.